SHARE
TWEET

Untitled

a guest Jan 19th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HANDLE Threads[THREAD_NUM]
  2.    
  3. void LaunchThread (int i) {
  4.   *some checks if the handle is not null etc*;
  5.   DWORD threadId;
  6.   threads[i] = CreateThread (
  7.     NULL,
  8.     0,
  9.     (LPTHREAD_START_ROUTINE)*StaticMethodInvokingTheThreadFunc,
  10.     *StructPassingToThatMethod ( basically have a pointer and thread number)*,
  11.     0,
  12.     &threadId);
  13.   *DebugMessage "thread created"*;
  14.   *DebugMessage "with id = (threadId)"*;
  15. }
  16.    
  17. void DoSmth () {
  18.   *DebugMessage "thread func started"*;
  19.   ...;
  20.   *then code with another messages all the way*;
  21. }
  22.    
  23. void WaitThread (i){
  24.   *DebugMessage "wait for thread to finish"*;
  25.   WaitForSingleObject (Threads[i], INFINITE);
  26. }
  27.    
  28. LaunchThread (i);
  29. WaitThread (i);
  30.    
  31. "thread created"
  32. "thread func started" (and nothing done after that message in DoSmth () func)
  33. "with id = .."
  34. "wait for thread to finish"
  35.    
  36. for ( int t = 0; t < THREAD_NUM; t++)
  37.    LaunchThread (t);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top