package cn.bunny.demo5;

import io.netty.channel.EventLoop;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.concurrent.Future;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TestAsyncFuture {
    public static void main(String[] args) {
        NioEventLoopGroup loopGroup = new NioEventLoopGroup();
        EventLoop eventLoop = loopGroup.next();
        Future<Integer> future = eventLoop.submit(() -> {
            log.debug("执行计算...");
            Thread.sleep(1000);
            return 70;
        });

        future.addListener(future1 -> log.debug("接受结果：{}", future1.getNow()));
    }
}
