OK, Since there is usually at least somebody on here at knows everything. Here comes a fun Java Question.
I have never done programming with multiple threads before. I have only used one thread to create a delayed loop. Using sleep.
What confuses me, is i want to have a main program that runs... then there are two threads one running every 100 ms and one running every 400 ms.
OK so far.
However, they also share resources. By that I mean, depending on the result of there execution on each thread it effects the program. I just don't know how to pass the variables around.
So for example.
there is a motor class
every 100 ms the motor heat sensor is checked. if its too high it stops the motor
then every 200ms the moisture sensor is checked. if its too high the motor stops.
(if the motor is not running and the sensors are not too high they start the motor)
Can anybody give me a rough pointer as to where to start with this. As i see it so far,
Main Class (initializes, starts threads)
heat sensor class (polls heat)
moisture sensor class (polls moisture)
motor class (manages motor on/off etc.)
I just don't know how to get the information from the threads to the motor class.
Thanks again, hope this makes sense :-/