19.Future&Microtask
多个 Future
void main() {
Future( () {
sleep(const Duration(seconds: 1));
return "${DateTime.now()}: 1";
})
.then((value){
print(value);
});
Future( () {
sleep(const Duration(seconds: 1));
return "${DateTime.now()}: 2";
})
.then((value){
print(value);
});
Future( () {
sleep(const Duration(seconds: 1));
return "${DateTime.now()}: 3";
})
.then((value){
print(value);
});
Future( () {
sleep(const Duration(seconds: 1));
return "${DateTime.now()}: 4";
})
.then((value){
print(value);
});
}依赖连续调用
多个无依赖的任务结束后处理
scheduleMicrotask
题目
Last updated