aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/natThread.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/lang/natThread.cc')
-rw-r--r--libjava/java/lang/natThread.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/libjava/java/lang/natThread.cc b/libjava/java/lang/natThread.cc
index f778510..facce30 100644
--- a/libjava/java/lang/natThread.cc
+++ b/libjava/java/lang/natThread.cc
@@ -410,7 +410,8 @@ _Jv_SetCurrentJNIEnv (JNIEnv *env)
}
// Attach the current native thread to an existing (but unstarted) Thread
-// object. Returns -1 on failure, 0 upon success.
+// object. Does not register thread with the garbage collector.
+// Returns -1 on failure, 0 upon success.
jint
_Jv_AttachCurrentThread(java::lang::Thread* thread)
{
@@ -427,6 +428,8 @@ _Jv_AttachCurrentThread(java::lang::Thread* thread)
java::lang::Thread*
_Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group)
{
+ // Register thread with GC before attempting any allocations.
+ _Jv_GCAttachThread ();
java::lang::Thread *thread = _Jv_ThreadCurrent ();
if (thread != NULL)
return thread;
@@ -461,6 +464,7 @@ _Jv_DetachCurrentThread (void)
return -1;
_Jv_ThreadUnRegister ();
+ _Jv_GCDetachThread ();
// Release the monitors.
t->finish_ ();