spin() and Win32 port

Tom Tromey tromey@redhat.com
Wed Dec 18 14:22:00 GMT 2002


I let in a small change to natObject.cc that changed spin() to call
Thread::sleep instead of usleep().

I think this was a mistake (to be honest I don't recall seeing that
code in a patch, double oops on me).  spin() is used in the
implementation of _Jv_MonitorEnter; the point as I understand it is to
sleep a bit to avoid creating a heavyweight mutex.  However,
Thread::sleep() acquires just such a mutex -- defeating the purpose of
spin().

I'm planning to revert this patch, but I wanted to give the Win32
developers a heads-up.  I assume this went in in the first place due
to some problem with usleep on Win32.  Adam, Ranjit -- does this need
a new platform function for Win32?

Tom



More information about the Java mailing list