tag:blogger.com,1999:blog-7045524330253482541.post63042369280290473..comments2024-01-04T22:19:45.990-08:00Comments on Jim McBeath: Multithread Coroutine SchedulerJim McBeathhttp://www.blogger.com/profile/10541190774989580614noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7045524330253482541.post-28554125405447394152011-07-20T22:52:43.786-07:002011-07-20T22:52:43.786-07:00AndiHofi: Yes, in general that is a good rule. Si...AndiHofi: Yes, in general that is a good rule. Since in this case coWait is a version of wait, I expected the caller to determine whether he considers the wakeup spurious and re-invoke coWait, so I had not bothered to make that check myself within coWait.Jim McBeathhttps://www.blogger.com/profile/10541190774989580614noreply@blogger.comtag:blogger.com,1999:blog-7045524330253482541.post-30390520582235088682011-07-20T05:13:00.988-07:002011-07-20T05:13:00.988-07:00Because of the possibility of spurious wakeups you...Because of the possibility of spurious wakeups you should always use while loops when using wait/notify:<br /><br />defaultLock.synchronized {<br />while(!notified) defaultLock.wait()<br />notified = false<br />}AndiHofihttps://www.blogger.com/profile/02860289700522958513noreply@blogger.com