Nintendo 3DS >> C/C++ >> SDL v1.2

Thread


參考資訊:
1. libctru doc
2. 3ds-examples

說明:

API
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data)
void SDL_WaitThread(SDL_Thread *thread, int *status)

main.c

#include <stdio.h>
#include <3ds.h>
#include <SDL.h>
 
static int mythread(void *args)
{
    printf("%s++\n", __func__);
    SDL_Delay(1000);
    printf("%s--\n", __func__);
    return 0;
}
 
int main(void)
{
    int ret = 0;

    gfxInitDefault();
    consoleInit(GFX_TOP, NULL);

    printf("%s++\n", __func__);
    SDL_Thread *thread = SDL_CreateThread(mythread, NULL);
    SDL_WaitThread(thread, &ret);
    printf("%s--\n", __func__);

    gfxExit();
    return 0;
}

完成


返回上一頁