Created
September 6, 2019 19:59
-
-
Save yefim/cf571c23dd124fe79c17d3811f5a7302 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async { | |
final t1 = () => Future.delayed(Duration(seconds: 1), () => print('1')); | |
final t2 = () => Future.delayed(Duration(seconds: 3), () => print('3')); | |
final t3 = () => Future.delayed(Duration(seconds: 2), () => print('2')); | |
final timers = [t1, t2, t3]; | |
print('Running'); | |
Stopwatch stopwatch = new Stopwatch()..start(); | |
// for (final timer in timers) { | |
// await timer(); | |
// } | |
await Future.wait(timers.map((timer) => timer())); | |
print('executed in ${stopwatch.elapsed}'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment