Mon programme multithread ( win32 ) est involontairement infini
Bonjour,
J'ai écrit un programme multithread avec win32 mais son execution ne se termine jamais. Pourriez vous m'aider ?
Voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| DWORD WINAPI MaClasse::thread0(LPVOID lpParam)
{
LoadingThreadsParameters *parameters = (LoadingThreadsParameters*)lpParam;
unsigned short beginning = parameters->beginning;
unsigned short end = parameters->end;
for (unsigned short i = beginning; i < end ; i++)
{
//code
}
return 1;
}
DWORD WINAPI MaClasse::thread1(LPVOID lpParam)
{
LoadingThreadsParameters *parameters = (LoadingThreadsParameters*)lpParam;
unsigned short beginning = parameters->beginning;
unsigned short end = parameters->end;
for (unsigned short i = beginning; i < end ; i++)
{
//code
}
return 1;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| LoadingThreadsParameters loadingThreadsParameters0;
LoadingThreadsParameters loadingThreadsParameters1;
loadingThreadsParameters0.beginning = 0;
loadingThreadsParameters0.end = nbObj/2;
handleThread[0] = CreateThread(
NULL, // default security attributes
0, // use default stack size
&MaClasse::thread0, // thread function name
&threadsParameters0, // argument to thread function
0, // use default creation flags
0);
threadsParameters1.beginning = nbObj / 2;
threadsParameters1.end = (nbObj+1);
handleThread[1] = CreateThread(
NULL, // default security attributes
0, // use default stack size
&MaClasse::thread1, // thread function name
&threadsParameters1, // argument to thread function
0, // use default creation flags
0);
WaitForMultipleObjects(2, handleLoadingTexturesThread, TRUE, INFINITE); |