Yield method in threads
2 posts in topic
Flat View  Flat View

Posted By:   Manu_Gupta
Posted On:   Thursday, July 28, 2005 03:57 PM

Does calling the yield method on a thread only allows any other higher or equal priority thread to execute or can a lower priority thread execute.

Re: Yield method in threads

Posted By:   Jani_Kaarela  
Posted On:   Friday, July 29, 2005 03:57 AM

A word of caution... Threading behaviour is quite undeterministic and depends on the particular JVM implementation. I would strongly recommend against designs that depend on the intricate details of threading.

Keep it simple, stick to wait()/notify() constructs, and if need be, use Doug Lea's concurrency package for mutexes and other threading constructs. Some recommend calling yield() or sleep() every now and then in potentially time-consuming loops and such, but OTOH, on many implementations yield() is practically ignored.

Re: Yield method in threads

Posted By:   Almagest_FUTT  
Posted On:   Thursday, July 28, 2005 04:57 PM

Yes, lower-priority threads can get cputime.
The thread's priority basically determines the likeliness of the thread getting cputime at a specific time point.
About | Sitemap | Contact