FutureTask 理解

1. FutureTask主要有三个方法:run/get/cancel

a. run

执行前如果state = NEW那么直接执行

执行前如果state !=NEW那么直接结束

执行中可能被cancel方法interrupt

b. get

run执行结束分两种情况:正常结束/Exception

正常结束get得到结果/Exception时get会throw Exception

c. cancel

将state置为CANCELLED,并且尝试interrupt

直接影响的就是run方法

猜你喜欢

转载自blog.csdn.net/u011385186/article/details/79096777