You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mi...@dartlang.org
I wrote some simple code to test the new async functionality but it is not working as I expect it to. I thought this would print both statements roughly at the same time but it only prints mom cooks.
Stopwatch mom = new Stopwatch();
Stopwatch dad = new Stopwatch();
Duration dur = new Duration(seconds: 1);
mymom() async {
mom.start();
while(true){
if(mom.elapsed > dur){
print('mom cooks'); //obviously
mom.reset();
}
}
}
mydad() async {
dad.start();
while(true){
if(dad.elapsed > dur){
print('dad works');
dad.reset();
}
}
}
main() {
mymom();
mydad();
print('also true');
}
TM
unread,
Nov 13, 2014, 7:40:38 PM11/13/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mi...@dartlang.org
Remember Dart is single-threaded. `Mom` executes strictly before `dad`;
there aren't two infinite loops running in parallel.
If you want to interleave the output, this will do it: