Skip to content

Instantly share code, notes, and snippets.

@yefim
Created September 6, 2019 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yefim/cf571c23dd124fe79c17d3811f5a7302 to your computer and use it in GitHub Desktop.
Save yefim/cf571c23dd124fe79c17d3811f5a7302 to your computer and use it in GitHub Desktop.
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