Jerry wrote...
>> > Initially all variables are 0
>> > Thread 1
>> > Volatile1 = 1
>> > while (A == 0) {;}
>> >
>> > Thread 2
>> > while (Volatile1 != 1) {;}
>>> print "Success"
>>>
> I do not believe there is currently any such requirement in either the JLS
> or JVMS and I would strongly oppose adding one. Oracle's RDBMS Server VM
> has entirely non-preemptive scheduling. Once Thread 2 gets into its loop
> that is all the VM does. Thread 1 never runs.
>
Mostly as point of information, what would happen in your JVM if these were
written as:
Thread 1
Volatile1 = 1
while (A == 0) { Thread.yield(); }
Thread 2
while (Volatile1 != 1) { Thread.yield(); }
The JLS allows the same behavior as without the yields.
-- Doug Lea, Computer Science Department, SUNY Oswego, Oswego, NY 13126 USA dl@cs.oswego.edu 315-312-2688 FAX:315-312-5424 http://gee.cs.oswego.edu/ ------------------------------- JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:35 EDT