The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Android thread
Owen Alanzo Hogarth
Guest

Hi guys,

quick question for the android guys on this list.


I am having a little trouble with the way sdl created it thread.


It seems that SDL on android is inherently single threaded based on the way the jni thread is setup.



static void Android_JNI_ThreadDestroyed(void* value)
{
    /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */
    JNIEnv *env = (JNIEnv*) value;
    if (env != NULL) {
        (*mJavaVM)->DetachCurrentThread(mJavaVM);
        pthread_setspecific(mThreadKey, NULL);
    }


and this line


static void Android_JNI_ThreadDestroyed(void* value)
{
    /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */
    JNIEnv *env = (JNIEnv*) value;
    if (env != NULL) {
        (*mJavaVM)->DetachCurrentThread(mJavaVM);
        pthread_setspecific(mThreadKey, NULL);
    }

}


This looks like the main thread that gets created on the java side where the mSDLthread is created.
I want to create and manage my own jni threads and manage them but I am a bit confused about how the SDL thread is attached to the JNI threads.
Anyone on here can provide some clarification?