SHARE
TWEET

Untitled

a guest Feb 20th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from multiprocessing import Process, Manager, Value
  2. from ctypes import c_char_p
  3. import time
  4.  
  5. def work1(string):
  6.     i = 2
  7.     string.value = i
  8.     #while True:
  9.         #string.value = i
  10.         #i = i + 1
  11.  
  12. def work2(string):
  13.     while True:
  14.         print(string.value)
  15.         time.sleep(2)
  16.  
  17. if __name__ == '__main__':
  18.     manager = Manager()
  19.     string = manager.Value(int, 0);
  20.  
  21.     p1=Process(target=work1, args=(string,))
  22.     p1.start()
  23.     p1.join()
  24.  
  25.     p2=Process(target=work2, args=(string,))
  26.     p2.start()
  27.     p2.join()
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