import threading
import time def music():
print("begin to listen %s" %time.ctime())
time.sleep(3)
print("stop to listen %s" %time.ctime()) def game():
print("begin to listen %s" % time.ctime())
time.sleep(5)
print("stop to listen1 %s" % time.ctime()) if __name__ =='__main__': t1 = threading.Thread(target=music) t2 = threading.Thread(target=game) t1.start()
# t1.join()
t2.start() # t1.join()
t2.join() print("ending") # l = []
#
# for i in range(2):
# threading.Thread(target=music)
相关文章
- 并发编程 - 协程 - 1.协程概念/2.greenlet模块/3.gevent模块/4.gevent实现并发的套接字通信
- python 并发编程 基于gevent模块实现并发的套接字通信
- python实现将多张图片结合为一张图片的方法
- vue 拓扑组件_vue 集成 vis-network 实现网络拓扑图的方法
- 单片机获取真实时间的实现方法
- idea 转换大小写在IntelliJ IDEA中,转换文本的大小写可以通过以下方法实现:使用快捷键Ctrl+Shift+U
- mysql+php实现选课系统中遇到的问题及解决方法
- springboot实现WebMvcConfigurer 自定义的configureMessageConverters方法不生效的问题
- react 函数式组件 使用的第二个参数完成路由传值的方法,此方法可类似于post传值,不在地址上显示。实现更优雅的传值
- HttpURLConnection的post请求传递header参数和body参数的具体方法实现