>>>>> "Joseph" == Joseph Shraibman <[EMAIL PROTECTED]> writes:
Joseph> Juergen Kreileder wrote:
>> Please note that it is perfectly legal with respect to the JLS
>> to implement Thread.yield() as nop in JVMs based LinuxThreads.
>> Actually it is not only legal, it's desirable to implement it
>> as nop on JVMs that employ preemptive scheduling policies
>> (especially on multiprocessor machines).
Joseph> Look, if Thread.yield() is ever called by the programmer,
Joseph> he has a reason for it. In my case, I'm calling it
Joseph> because I want the thread handling the rmi call to return
Joseph> before the thread that calls exit() calls exit() because I
Joseph> don't want the client to get an EOFException. With the
Joseph> 2.2.15 kernel it worked perfectly. With 2.4.0 it doesn't,
Joseph> and my clients are getting EOFExceptions.
Joseph> public void exit() throws RemoteException{
Joseph> new Thread((new Runnable(){
Joseph> public void run () { Thread.yield() ;
Joseph> System.exit(0); }
Joseph> })).start(); //allow this method to end so the
Joseph> client doesn't get an
Joseph> error.
This is non-portable code. Thread.yield() is not an adequate tool for
this task. Your code makes several assumptions about the underlying
VM/OS implementation and configuration. It may work with a specific
setup but -- as seen -- may break if you change something: In your
case it's likely that some change in the new kernel changed timing
just a little bit and now your code fails.
>> Given the loose semantics of Thread.yield(), it is merely a
>> pure heuristic *hint* to the JVM. The JVM may interpret this
>> hint in any way it likes.
Joseph> May doesn't mean should. I imagine the spec was so loose
Joseph> because it could be expected that fine control over the
Joseph> threading might not be available to the implementors of
Joseph> the jvm on every platform, not because the writers of the
Joseph> spec didn't think Thread.yield() would be useful.
Actually Thread.yield() is useful, it was added for VMs which do not
use time-sliced preemptive scheduling, e.g. the classic green threads
VM.
Juergen
--
Juergen Kreileder, Blackdown Java-Linux Team
http://www.blackdown.org/java-linux.html
JVM'01: http://www.usenix.org/events/jvm01/
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]