Netty中進行任務調度 LocalChannel

1.60秒後調用一次

Channel channel = new LocalChannel();
channel.eventLoop().schedule(() -> {
    System.out.println("60s!");
}, 60, TimeUnit.SECONDS);
 



oop

2.每隔60秒調用一次

ScheduledFuture sf = channel.eventLoop().scheduleAtFixedRate(() -> {
    System.out.println("every 60s!");
}, 60, 60, TimeUnit.SECONDS);
sf.cancel(false);
 

原文連接:https://blog.csdn.net/zhwwwcomcn123/article/details/106857404





spa

相關文章
相關標籤/搜索