>>线程操作队列
# 线程操作队列
'''
线程队列操作方法
def __init__(self,maxsize)
def put(self,item,block=True,timeout=None) # 像队列保存数据
def get(self,block=True,timeout=None) # 从队列获取数据
def qsize(self)
def empty(self)
def full(self)
def join(self)
'''
import threading ,time,queue
import time
def pd (q):
for i in range(100):
q.put('人生等只如初见%s'%i)
def cs(q):
while q.qsize()>0:
time.sleep(0.8)
q.get()
print(q.get())
if q.full():
time.sleep(1)
def main():
q=queue.Queue(10)
t1 = threading.Thread(target=pd,args=(q,))
t2 =threading.Thread(target=cs,args=(q,))
t1.start()
t2.start()
t1.join()
t2.join()
if __name__ == '__main__':
main()