fix custom-classloader-related concurrency problems and other bugs

The main changes in this commit ensure that we don't hold the global
class lock when doing class resolution using application-defined
classloaders.  Such classloaders may do their own locking (in fact,
it's almost certain), making deadlock likely when mixed with VM-level
locking in various orders.

Other changes include a fix to avoid overflow when waiting for
extremely long intervals and a GC root stack mapping bug.
This commit is contained in:
Joel Dice
2010-09-16 19:43:27 -06:00
parent f485016637
commit d0d53e2e10
12 changed files with 337 additions and 232 deletions

View File

@ -15,7 +15,7 @@ import java.util.WeakHashMap;
public class Thread implements Runnable {
private long peer;
private boolean interrupted;
private volatile boolean interrupted;
private boolean daemon;
private byte state;
private byte priority;
@ -141,25 +141,9 @@ public class Thread implements Runnable {
public static native Thread currentThread();
private static native void interrupt(long peer);
public native void interrupt();
public synchronized void interrupt() {
if (peer != 0) {
interrupt(peer);
} else {
interrupted = true;
}
}
public static boolean interrupted() {
Thread t = currentThread();
synchronized (t) {
boolean v = t.interrupted;
t.interrupted = false;
return v;
}
}
public native boolean interrupted();
public static boolean isInterrupted() {
return currentThread().interrupted;