title: Python - Multithreading - Does Lock have to be global?
body: <p>I am beginner of multithreading in python.<br>
  I want to use a Lock in threads. Does it have to be declared global in the thread?
  My code looks like this:</p>
  
  <pre><code>i = 0
  lock = threading.RLock()
  def do_work():
    global i
    # global lock ?????????????
    while i &lt; len(my_list):
      lock.acquire()
      my_i = i
      i += 1
      lock.release()
      my_list[my_i].some_works()
  
  workers = [threading.Thread(target=do_work) for _ in range(8)]
  for worker in workers:
    worker.start()
  </code></pre>