title: how to sync two contantly running threads using event?
body: <p>I am trying to run a few lines in thread1 according to an event from thread2. Both threads run constantly in a "while True" loop.
  The problem is that I can't seem to run the requied lines ONLY when the event is occuring.</p>
  
  <p>BTW, both threads use a shared resouce (list) and can be synched using Lock method. This also did not work for me.</p>
  
  <pre><code>frames_list = []
  new_frame = Event()
  result = 0
  
  
  def thr1():
      global frames_list
      global frames_list_max_size
      global result
      while True:
          new_frame.set()
          result = result + 1
          new_frame.clear()
  
  
  def thr2():
      global result
      while True:
          new_frame.wait()
          print(datetime.datetime.now())
          print(result)
  
  
  threads = []
  for func in [thr1, thr2]:
      threads.append(Thread(target=func))
      threads[-1].start()
  
  for thread in threads:
      thread.join()
  </code></pre>
  
  <p>result for example:</p>
  
  <pre><code>2019-10-19 22:35:34.150852
  1710538
  2019-10-19 22:35:34.173803
  1722442
  2019-10-19 22:35:34.197736
  1737844
  2019-10-19 22:35:34.214684
  1740218
  2019-10-19 22:35:34.220664
  1749776
  </code></pre>
  
  <p>I would expect:
     1. time diff between every print would be 1 sec.
     2. result would increment by 1 for every print.</p>