02 2021 档案
摘要:对应示例代码,回调函数不会阻塞 import time from concurrent.futures import ThreadPoolExecutor def get(delay): print('delay {}s'.format(delay)) time.sleep(delay) # 延时
阅读全文
摘要:一、简介 常用的有如下几种方式 synchronized(this)、synchronized(Object)与synchronized修饰静态方法、synchronized(class) 二、修饰本身对象 如下两种写法是具有一样的效果,都是锁住自己本身的对象,当同一对象多次调用时,同步锁会起作用。
阅读全文