I programm C in VS Code with the gcc/gdb compiler/dubugger and SDL2. What happens is, that when I create threads via SDL2_CreateThread the debugger seems to hold before finishing the programm.
create threads like:
//doing this every frame
int THREADN = 20;
SDL_Thread *treds[THREADN];
for(int i = 0; i < THREADN; i++)
treds[i] = SDL_CreateThread(someFunc, "Timstred", NULL); //someFunc doesnt even have to do anything
for(int i = 0; i < THREADN; i++)
SDL_WaitThread(treds[i], NULL);
The last two lines of my main function are:
printf("hello");
return 0; // return of main function
In VS Code terminal it prints hello but doesnt finish:
with finish i mean until it return to my directory command line thing:
normally I wouldnt have bothered about this, cause it normally takes like 3 sec to finish, but it actually depends on how long the programm was running and how many threads are used. If i use 20 threads and let it run for a few minute it takes really long like 30 seconds to finish. If I start the programm without the debugger it instantly finishes when i close it. I am just worried that the debugger has to clean up a mess that i left with my threads or somthing.