Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7782
| Date | 2011-09-10 22:42 -0700 |
|---|---|
| From | Patricia Shanahan <pats@acm.org> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java thread |
| References | <128ea2e0-7a2e-4c86-9507-8e15a0b892b9@p25g2000pri.googlegroups.com> |
| Message-ID | <UoudnVs6Zbf11_HTnZ2dnUVZ_uCdnZ2d@earthlink.com> (permalink) |
On 9/10/2011 9:03 PM, Jack wrote: > For Java thread, how to ensure that wait() does not miss notify()? > Otherwise the thread will hang and can not shut down. I'm not quite sure what you are asking, but here are a couple of possible answers - if neither fits, consider a more detailed question. 1. wait and notify can only be called in synchronized code. The wait code should check that it is supposed to wait inside the same synchronized block. The notify code should only change whatever controls whether to wait inside the same synchronized block as the notify. 2. If you are using a current version of Java, check the java.util.concurrent package. A lot of things that used to be done with explicit wait-notify code can instead be done using concurrent queues, barriers etc. Patricia
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Java thread Jack <junw2000@gmail.com> - 2011-09-10 21:03 -0700
Re: Java thread markspace <-@.> - 2011-09-10 21:34 -0700
Re: Java thread Patricia Shanahan <pats@acm.org> - 2011-09-10 22:42 -0700
Re: Java thread Jack <junw2000@gmail.com> - 2011-09-10 22:48 -0700
Re: Java thread Owen Jacobson <angrybaldguy@gmail.com> - 2011-09-11 03:07 -0400
Re: Java thread Lew <lewbloch@gmail.com> - 2011-09-11 09:37 -0700
Re: Java thread Arne Vajhøj <arne@vajhoej.dk> - 2011-09-11 16:56 -0400
Re: Java thread Arne Vajhøj <arne@vajhoej.dk> - 2011-09-11 09:34 -0400
Re: Java thread Roedy Green <see_website@mindprod.com.invalid> - 2011-09-11 08:32 -0700
csiph-web