偶然发现异步延迟示例介绍我在Java中的异步实现中发现缺少示例。下面是一些代码示例主仓库例子最简单的例子
/**
-
simplest with only 1 defer
-
@param args
*/
public static void main1(String[] args) {
try {
Deferred<String> dfd = new Deferred<String>();
Callback<String> cb = new MyCallback();
dfd.addCallback(cb);
System.out.println(\"test\");
Thread.sleep(4000);
dfd.callback(\"callback data after 4 seconds aaa\");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
暂无评论