用户登录
用户注册

分享至

Python协程

  • 作者: 和女朋友分手后重回段子圈
  • 来源: 51数据库
  • 2022-08-12
def thread1():  
    for x in range(4):  
        yield x  
          
  
def thread2():  
    for x in range(4,8):  
        yield x  
          
  
threads=[]  
threads.append(thread1())  
threads.append(thread2())  
  
  
def run(threads):  
    for t in threads:  
        try:  
            print t.next()  
        except StopIteration:  
            pass  
        else:  
            threads.append(t)   
  
run(threads)  
软件
前端设计
程序设计
Java相关