Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HANDLE Threads[THREAD_NUM]
- void LaunchThread (int i) {
- *some checks if the handle is not null etc*;
- DWORD threadId;
- threads[i] = CreateThread (
- NULL,
- 0,
- (LPTHREAD_START_ROUTINE)*StaticMethodInvokingTheThreadFunc,
- *StructPassingToThatMethod ( basically have a pointer and thread number)*,
- 0,
- &threadId);
- *DebugMessage "thread created"*;
- *DebugMessage "with id = (threadId)"*;
- }
- void DoSmth () {
- *DebugMessage "thread func started"*;
- ...;
- *then code with another messages all the way*;
- }
- void WaitThread (i){
- *DebugMessage "wait for thread to finish"*;
- WaitForSingleObject (Threads[i], INFINITE);
- }
- LaunchThread (i);
- WaitThread (i);
- "thread created"
- "thread func started" (and nothing done after that message in DoSmth () func)
- "with id = .."
- "wait for thread to finish"
- for ( int t = 0; t < THREAD_NUM; t++)
- LaunchThread (t);
Add Comment
Please, Sign In to add comment