Quote:
Originally Posted by Aaron V
So I have experience in programming - but one thing I haven't really looked into in detail are threads - I've always just let the compiler deal with them for me. I understand the concept of threads. The different parts of a programmer running essentially at the same time (alternating fast enough so that it doesn't really make a difference). I just don't understand what parts of a program constitutes as a difference thread. I've written a few additional classes for organisational purposes - do they have any effect?
Basically my main problem is that I need to pulse solenoids. It's simple to set it open or closed based on other input, but I don't know how to use time as an input. I figure I need threads because I don't want to stop everything else in the code.
Finally I've both seen the wait() function in the object class and the delay() function in the Timer class - I'm not sure which is better to use and which thread it effects.
|
Pulse solenoids, eh? Take a closer look at the
Timer class, more notably getFPGATimestamp(). What I'd do is create a double to store a current timestamp using getFPGATimestamp(). Then in my code I'd make another more recent one that checks for a change in time. If the time has changed, I'd simply set the solenoid to false. Put that baby in a loop and bam!
Now if you'd prefer putting it in a thread than a loop, just make a Runnable interface and thread it.
Hope I helped.