/* src/native/vm/cldc1.1/java_lang_Thread.c
- Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
- R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
- C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
- Institut f. Computersprachen - TU Wien
+ Copyright (C) 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "config.h"
+
+#include <stdint.h>
+
#include "vm/types.h"
#include "native/jni.h"
#include "native/include/java_lang_Thread.h"
-#include "native/vm/java_lang_Thread.h"
-
-#include "threads/threads-common.h"
+#include "threads/thread.h"
#include "toolbox/logging.h"
*/
JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz)
{
- return _Jv_java_lang_Thread_currentThread();
+ java_lang_Thread *to;
+
+ to = (java_lang_Thread *) thread_get_current_object();
+
+ return to;
}
*/
JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, java_lang_Thread *this, s4 oldPriority, s4 newPriority)
{
- _Jv_java_lang_Thread_setPriority(this, newPriority);
+#if defined(ENABLE_THREADS)
+ threadobject *t;
+
+ t = (threadobject *) this->vm_thread;
+
+ /* The threadobject is null when a thread is created in Java. The
+ priority is set later during startup. */
+
+ if (t == NULL)
+ return;
+
+ threads_set_thread_priority(t->tid, newPriority);
+#endif
}
*/
JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 millis)
{
- _Jv_java_lang_Thread_sleep(millis);
+#if defined(ENABLE_THREADS)
+ threads_sleep(millis, 0);
+#endif
}
*/
JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, java_lang_Thread *this)
{
- _Jv_java_lang_Thread_start(this, 0);
+#if defined(ENABLE_THREADS)
+ threads_thread_start((java_handle_t *) this);
+#endif
}
* Method: isAlive
* Signature: ()Z
*/
-JNIEXPORT s4 JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread *this)
+JNIEXPORT int32_t JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread *this)
{
- return _Jv_java_lang_Thread_isAlive(this);
+#if defined(ENABLE_THREADS)
+ threadobject *t;
+ bool result;
+
+ t = (threadobject *) this->vm_thread;
+
+ if (t == NULL)
+ return 0;
+
+ result = threads_thread_is_alive(t);
+
+ return result;
+#else
+ /* If threads are disabled, the only thread running is alive. */
+
+ return 1;
+#endif
}