summaryrefslogtreecommitdiff
path: root/libjava/posix-threads.cc
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2001-05-21 23:47:48 -0700
committerPer Bothner <bothner@gcc.gnu.org>2001-05-21 23:47:48 -0700
commitc93d7fae7b9825449c023d42eb40641c0ad80be2 (patch)
treeecfc0fb5d915f5f6596ef061114d1b6b7ec5270a /libjava/posix-threads.cc
parentb4fbaca7cb5c6ff5fb5e24e554d510257cb488eb (diff)
downloadgcc-c93d7fae7b9825449c023d42eb40641c0ad80be2.tar.gz
Implement invocation interface; don't create new thread for main.
From-SVN: r42428
Diffstat (limited to 'libjava/posix-threads.cc')
-rw-r--r--libjava/posix-threads.cc27
1 files changed, 20 insertions, 7 deletions
diff --git a/libjava/posix-threads.cc b/libjava/posix-threads.cc
index c38cee6f8ae..286bf83116f 100644
--- a/libjava/posix-threads.cc
+++ b/libjava/posix-threads.cc
@@ -326,6 +326,25 @@ _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio)
}
}
+void
+_Jv_ThreadRegister (_Jv_Thread_t *data)
+{
+ pthread_setspecific (_Jv_ThreadKey, data->thread_obj);
+ pthread_setspecific (_Jv_ThreadDataKey, data);
+
+ // glibc 2.1.3 doesn't set the value of `thread' until after start_routine
+ // is called. Since it may need to be accessed from the new thread, work
+ // around the potential race here by explicitly setting it again.
+ data->thread = pthread_self ();
+}
+
+void
+_Jv_ThreadUnRegister ()
+{
+ pthread_setspecific (_Jv_ThreadKey, NULL);
+ pthread_setspecific (_Jv_ThreadDataKey, NULL);
+}
+
// This function is called when a thread is started. We don't arrange
// to call the `run' method directly, because this function must
// return a value.
@@ -334,13 +353,7 @@ really_start (void *x)
{
struct starter *info = (struct starter *) x;
- pthread_setspecific (_Jv_ThreadKey, info->data->thread_obj);
- pthread_setspecific (_Jv_ThreadDataKey, info->data);
-
- // glibc 2.1.3 doesn't set the value of `thread' until after start_routine
- // is called. Since it may need to be accessed from the new thread, work
- // around the potential race here by explicitly setting it again.
- info->data->thread = pthread_self ();
+ _Jv_ThreadRegister (info->data);
info->method (info->data->thread_obj);