Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import threading
- # Threaded function-call -------------------------------------------------------
- def counter(x):
- for i in xrange(x):
- print i
- time.sleep(1)
- t = threading.Thread(target = counter, args = [30])
- t.start()
- # Thread-class subclassing -----------------------------------------------------
- class CounterThread(threading.Thread):
- def __init__(self, x):
- super(CounterThread, self).__init__() # DO NOT FORGET THIS !
- self.x = x
- def run(self):
- for i in xrange(self.x):
- print i
- time.sleep(1)
- t = CounterThread(30)
- t.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement