Thread.interrupt()
Boehm, Hans
hans_boehm@hp.com
Tue Mar 14 11:26:00 GMT 2000
I think we are asking two different questions, and I'm probably overly
optimistic.
If the question is: "Can Thread.interrupt() be implemented in terms of
pthread_cancel,
without relying on undocumented properties the pthread implementation?" then
the answer
is almost certainly no.
But there are lots of things you can't do without relying on extensions to
the pthreads
implementation (e.g. garbage collection, reasonable cost reference counting,
etc.)
So my question was really: "Can I extend the pthreads
implementation/documentation such that
Thread.interrupt() is implementable in terms of pthread_cancel()?" In that
case,
the answer is likely to be "yes".
It seems to me that this is a reasonable approach for getting the
functionality on Linux.
Java is likely to eventually be either the most important client of
pthreads, or certainly
one of the most important clients. Adding minor extensions to make them
cooperate seems
more than reasonable.
It does mean that you won't get instantaneous support for this feature on
all platforms.
But at least you have a path to get there on each platform.
I haven't a clue whether, for example, the linux_threads implementation,
would actually
need to be changed. Certainly more of its behavior would have to be exposed
to gcj.
(I implemented this once in a different context while I was working for SGI.
My recollection
is that in that case essentially no pthread code changes were required in
the end.)
Hans
-----Original Message-----
From: Tom Tromey [ mailto:tromey@cygnus.com ]
Sent: Tuesday, March 14, 2000 10:52 AM
To: Boehm, Hans
Cc: 'Miles Sabin'; java-discuss@sourceware.cygnus.com
Subject: RE: Thread.interrupt()
Hans> It seems to me that Thread.interrupt() should in fact be
Hans> implemented (on Posix platforms) using pthread_cancel, though it
Hans> may take some work on the pthreads side to make that fly.
I don't see how this can be done, because I don't see how you can stop
a cancellation in progress (eg, throwing an exception from a cleanup
handler is undefined behavior). Bryce and I have been talking about
just implementing condition variables on our own for POSIX, since the
POSIX and Java models don't line up enough. I'd love to be wrong
about this.
Tom
More information about the Java
mailing list