Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. static GlobalData g;
  2.  
  3. void thread1()
  4. {
  5.     while(true) {
  6.         if (g.ptr)
  7.             g.ptr->method();
  8.     }
  9. }
  10.  
  11. void thread2()
  12. {
  13.    g.ptr = new Game();
  14.    g.ptr->run();
  15.    delete g.ptr;
  16. }
  17.  
  18. void main()
  19. {
  20.    start_thread1();
  21.    start_thread2();
  22.  
  23.    do_something_else();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement