-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread5.py
More file actions
29 lines (26 loc) · 701 Bytes
/
thread5.py
File metadata and controls
29 lines (26 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import threading
import time
import Queue
def hello(start,end):
print start,end
class Producer(threading.Thread):
def __init__(self,t_name,target=hello,kwargs={"start":0,"end":10}):
threading.Thread.__init__(self,target=hello,name=t_name,kwargs=kwargs)
class Customer(threading.Thread):
def __init__(self,t_name):
threading.Thread.__init__(self,name=t_name)
def run(self):
for x in range(10):
count = queue.get()
print "custome %s"%(count)
time.sleep(0.2)
queue = Queue.Queue()
def main():
producer = Producer("producer")
#customer = Customer("customer")
producer.start()
#print "start producer"
#customer.start()
#print "start customer"
if __name__ == "__main__":
main()