Some of the best thread programming advice I've ever read was to never use Thread.yield() or mess with thread priorities or ThreadGroups in Java. In my opinion, it's a mistake in the Java API that we even have the *idea* of Thread.yield() and priorities for the very reason that we *like* to program in Java -- it is abstracted from the operating system. As Hui pointed out, scheduling is better handled by the kernel.

Program control using threads in Java should be controlled by blocking and notifying. Read "Effective Java Programming Language Guide" by Joshua Block for some good tips on how to use threads correctly in Java. Claiming laziness on this issue will eventually get you into trouble if the project is big enough.

[EMAIL PROTECTED] wrote:
On Thu, 6 Feb 2003, Hui Huang wrote:

They don't really want to be kicked out of CPU. But you have to
have those yield()'s inserted into a program because otherwise

I think we've lost a little context here. This started out when I said that instead of not doing anything Thread.yield() could be implemented as sleep(1).

That being said, by default Sun's JDK converts Thread.yield()
directly to sched_yield() on Linux.

Last time it came up on the list the conclusion was that Thread.yield() wasn't implemented to do anything. Maybe that's changed.


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


--
Matthew Avery
Senior Developer
(513) 470-5316
http://www.einnovation.com/
eInnovation, Inc., located in the heart of the midwest, invents and promotes eBusiness software that moves business technology to open standards.


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to