SDL_threadID SDL_GetThreadID(SDL_Thread* thread)
thread | 調査するスレッド |
#include <stdio.h>
#include "SDL_thread.h"
#include "SDL_timer.h"
// とても簡単なスレッド - 50ms間隔で0から9までカウントする
int TestThread(void *ptr)
{
int cnt;
for (cnt = 0; cnt < 10; ++cnt) {
printf("\nスレッドカウンタ: %d", cnt);
SDL_Delay(50);
}
return cnt;
}
int main(int argc, char *argv[])
{
SDL_Thread *thread;
int threadReturnValue;
printf("\nSDL_CreateThreadの簡単なテスト:");
// Simply create a thread
thread = SDL_CreateThread(TestThread, "TestThread", (void *)NULL);
if (NULL == thread) {
printf("\nSDL_CreateThread 失敗: %s\n", SDL_GetError());
} else {
SDL_WaitThread(thread, &threadReturnValue);
printf("\nスレッドの戻り値: %d", threadReturnValue);
}
return 0;
}