Quote:
Originally Posted by Colby Skeggs
I am well aware of this "solution".
I said "reasonably implement". Your suggestion, as I truly hope you know, pegs CPU usage at 100% and consumes all available processing power. This is not reasonable, except in very specific use cases.
Also, if you try this on the cRIO under Java, you'll notice that it hangs every single thread other than the main thread for the duration, because Squawk does cooperative multitasking and this code has no "Thread.yield()". (It's still a bad idea in C++, of course, but not quite as horrendous.)
|
The cRIO's Java threading is cooperative? Ick! I'm tempted to go read the Java specification to see if that's even allowed.
EDIT: Went and read the Java spec. This does appear to be allowed. In particular, the sections where it mentions the "sleep" containts an implicit yield and the section where it says that having one thread "diverge" (aka infinite loop with no observable effects) means that all threads are allowed to do so. I am now very happy not to be writing Java.