多线程超时熔断模型

1

new Thread B {}.run();

b.join(t);

b.inturrupt();

2

future b

b.get(t);

catch timeout exception() {b.cancel()};

3

Thread daemon {sleep(t);    b.inturrupt();}

https://blog.csdn.net/wonking666/article/details/76552019

4

timer/schedule thread pool of jdk,HashedWheelTimer of netty

https://mp.weixin.qq.com/s?__biz=MzIwMzY1OTU1NQ==&mid=2247484184&idx=1&sn=3c40f97e72dc33a429d48e435d93babe&chksm=96cd4354a1baca42ba7797265e4789e05e9a956c415bd2f66aa03cd9db71f4b58b52ced830d9&mpshare=1&scene=1&srcid=0612pdqhfYrJ9vQFZMy7lb9l&key=5c6fdbbf5ef80a2a5e0870152be4d696d1a76ad537676570456a89c531de5d4a9dfb751da096fdd8e2ef9adeb513107ec446339b9eb35e1b9885bae1ca50dc115108dc9ecf50391db7a952f318fccdab&ascene=0&uin=MTA2NzUxMDAyNQ%3D%3D&devicetype=iMac+MacBookAir6%2C2+OSX+OSX+10.10.5+build(14F2511)&version=11020012&lang=zh_CN&pass_ticket=eq%2FlKAH01NxZfya9OskycmeYcwhMR7GeHGM%2FxbG1JivSJgjyuLjUggri5NDTSxPk

3 4方法本质是一样的,用另一个线程监视,t时间后执行inturrupt,缺点是线程较多,开销大

猜你喜欢

转载自www.cnblogs.com/silyvin/p/9657310.html