test/testthread.c
changeset 7393 358696c354a8
parent 7391 a29895dc5e9a
child 7517 965d57022c01
equal deleted inserted replaced
7392:7e32fcb41b44 7393:358696c354a8
    31 }
    31 }
    32 
    32 
    33 int SDLCALL
    33 int SDLCALL
    34 ThreadFunc(void *data)
    34 ThreadFunc(void *data)
    35 {
    35 {
    36     SDL_TLSSet(tls, "baby thread");
    36     SDL_TLSSet(tls, "baby thread", NULL);
    37     printf("Started thread %s: My thread id is %lu, thread data = %s\n",
    37     printf("Started thread %s: My thread id is %lu, thread data = %s\n",
    38            (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
    38            (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
    39     while (alive) {
    39     while (alive) {
    40         printf("Thread '%s' is alive!\n", (char *) data);
    40         printf("Thread '%s' is alive!\n", (char *) data);
    41         SDL_Delay(1 * 1000);
    41         SDL_Delay(1 * 1000);
    64         return (1);
    64         return (1);
    65     }
    65     }
    66 
    66 
    67     tls = SDL_TLSCreate();
    67     tls = SDL_TLSCreate();
    68     SDL_assert(tls);
    68     SDL_assert(tls);
    69     SDL_TLSSet(tls, "main thread");
    69     SDL_TLSSet(tls, "main thread", NULL);
    70     printf("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
    70     printf("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
    71 
    71 
    72     alive = 1;
    72     alive = 1;
    73     thread = SDL_CreateThread(ThreadFunc, "One", "#1");
    73     thread = SDL_CreateThread(ThreadFunc, "One", "#1");
    74     if (thread == NULL) {
    74     if (thread == NULL) {