Charles Oliver Nutter
3/22/2008 6:06:00 AM
MenTaLguY wrote:
> On Sat, 15 Mar 2008 01:00:49 +0900, Roger Pack <rogerpack2005@gmail.com> wrote:
>> It was the problems with timeout that make me wish we had an
>> EnsureCritical (an Ensure that gets Thread.critical=true set to it
>> before entering it), so that timeouts can end properly.
>
> Anything using Thread.critical has its own problems, particularly
> when native threads are involved. It can easily result in deadlocks
> if the running thread inadvertently tries to use something which another
> stopped thread is using (imagine a thread stopped halfway through
> releasing a lock that the ensure block needs to acquire, for example
> -- something which would have worked fine with normal use of locks, but
> becomes a problem once threads can "stop the world").
And to clarify, this problem isn't restricted to native threads...even a
green-threaded model could deadlock if one thread goes critical while
other threads are holding unrelated locks.
- Charlie