X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fthreads%2Fthread.cpp;h=15bd67c5898826a6025cd91ea238c058cec4be1e;hb=9c1aaf5e763988911dc3c22c8a52e1cb31c2727c;hp=c8c3abcd808529d7ee6714051bd2b2a2177b6717;hpb=dd755df424bdff2cef6660dfd47f7160c2495ed8;p=cacao.git diff --git a/src/threads/thread.cpp b/src/threads/thread.cpp index c8c3abcd8..15bd67c58 100644 --- a/src/threads/thread.cpp +++ b/src/threads/thread.cpp @@ -139,6 +139,10 @@ void threads_preinit(void) mainthread = thread_new(THREAD_FLAG_JAVA); + /* Add the thread to the thread list. */ + + ThreadList::add_to_active_thread_list(mainthread); + /* The main thread should always have index 1. */ if (mainthread->index != 1) @@ -280,6 +284,10 @@ static threadobject *thread_new(int32_t flags) t = ThreadList::get_free_thread(); + /* Unlock the thread lists. */ + + ThreadList::unlock(); + if (t != NULL) { /* Equivalent of MZERO on the else path */ @@ -343,14 +351,6 @@ static threadobject *thread_new(int32_t flags) threads_impl_thread_reuse(t); - /* Add the thread to the thread list. */ - - ThreadList::add_to_active_thread_list(t); - - /* Unlock the thread lists. */ - - ThreadList::unlock(); - return t; } @@ -403,6 +403,10 @@ bool threads_thread_start_internal(utf *name, functionptr f) t = thread_new(THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON); + /* Add the thread to the thread list. */ + + ThreadList::add_to_active_thread_list(t); + /* The thread is flagged as (non-)daemon thread, we can leave the mutex. */ @@ -454,15 +458,16 @@ void threads_thread_start(java_handle_t *object) t->flags |= THREAD_FLAG_DAEMON; #endif - /* The thread is flagged and (non-)daemon thread, we can leave the - mutex. */ - - threads_mutex_join_unlock(); - /* Link the two objects together. */ thread_set_object(t, object); + /* Add the thread to the thread list. */ + + ThreadList::add_to_active_thread_list(t); + + threads_mutex_join_unlock(); + ThreadRuntime::setup_thread_vmdata(jlt, t); /* Start the thread. Don't pass a function pointer (NULL) since @@ -517,6 +522,10 @@ bool thread_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) /* The thread is flagged and (non-)daemon thread, we can leave the mutex. */ + /* Add the thread to the thread list. */ + + ThreadList::add_to_active_thread_list(t); + threads_mutex_join_unlock(); DEBUGTHREADS("attaching", t);