Merged to new trunk.
[cacao.git] / src / threads / thread.h
index 61ddbfd8a4dd6556fa4c6d314026b9ae73e1d32e..309de1a9bc9d4d7216b14d154f67355f56a04393 100644 (file)
@@ -206,7 +206,17 @@ inline static bool thread_is_attached(threadobject *t)
 
 inline static bool thread_is_interrupted(threadobject *t)
 {
-       return t->interrupted;
+       bool interrupted;
+
+       /* We need the mutex because classpath will call this function when
+          a blocking system call is interrupted. The mutex ensures that it will
+          see the correct value for the interrupted flag. */
+
+       mutex_lock(&t->waitmutex);
+       interrupted = t->interrupted;
+       mutex_unlock(&t->waitmutex);
+
+       return interrupted;
 }