title: Using lock in sub class of threading.Thread in python3
body: <p>I wanted to ask a question regarding the following code: suppose we wanted to build a <code>threading.Thread</code> subclass <code>ThreadCounter</code>, such that it has as arugment a name, an initial value and a terminal value and once started it increments the initial value up until it is equal to the terminal one.</p>
  <pre><code>import threading
  from threading import Thread
  import time
  
  lock = threading.Lock()
  
  class ThreadCounter(Thread):
     def __init__(self, nome, first, limit, lock):
         # Call the Thread class's init function
         Thread.__init__(self)
         self.nome = nome
         self.first = first
         self.limit = limit
         self.lock = lock
         
     # Override the run() function of Thread class
     def run(self):
         while self.first &lt; self.limit:
             self.lock.acquire()
             self.first += 1
             print(self.nome,self.first)
             time.sleep(3)
             
             self.lock.release()
             
           
  t1 = ThreadCounter('Thread-1', 1, 5, lock)
  t2 = ThreadCounter('Thread-2', 2, 10, lock)
  t1.start()
  t2.start()
  t1.join()
  t2.join()
  </code></pre>
  <p>I do not understand what happens when we are using the locks in the two classes. In particular, are we assigning the same lock-object to both of the instances with the assignment</p>
  <pre><code>t1 = ThreadCounter('Thread-1', 1, 5, lock)
  t2 = ThreadCounter('Thread-2', 2, 10, lock)
  </code></pre>
  <p>Or we have a different lock object for every occurence of the ThreadCounter class, such that t1 and t2 do not share the same lock?</p>