Skip to content

Instantly share code, notes, and snippets.

@mockturtl
Last active August 29, 2015 14:09
Show Gist options
  • Save mockturtl/97c0e692034888524f74 to your computer and use it in GitHub Desktop.
Save mockturtl/97c0e692034888524f74 to your computer and use it in GitHub Desktop.
import 'dart:async';
Stopwatch mom = new Stopwatch();
Stopwatch dad = new Stopwatch();
Duration dur = new Duration(milliseconds: 400);
Future mymom() async {
if(mom.elapsed > dur){
print('mom cooks');
mom.reset();
}
mymom();
}
Future mydad() async {
if(dad.elapsed > dur){
print('dad works');
dad.reset();
}
mydad();
}
main() {
mom.start();
dad.start();
mymom();
mydad();
print('end of main');
}
@mockturtl
Copy link
Author

$ dart --version  # Dart VM version: 1.8.0-dev.4.0 (Wed Nov 12 01:25:30 2014) on "linux_x64"
$ dart -c --enable-async momdad.dart 
# end of main
# mom cooks
# dad works
# mom cooks
# dad works
# ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment