[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [stellation-res] Could someone please run this program in Windows?
|
> >-----Original Message-----
> >From: stellation-res-admin@xxxxxxxxxxxxxxx
> >[mailto:stellation-res-admin@xxxxxxxxxxxxxxx]On Behalf Of Dave Shields
> >Sent: September 12, 2002 5:41 PM
> >To: stellation-res@xxxxxxxxxxxxxxx
> >Subject: Re: [stellation-res] Could someone please run this program in
> >Windows?
> >
> >
> >On Thu, Sep 12, 2002 at 05:05:09PM -0400, Marco Qualizza wrote:
> >>
> >> Out of curiousity, why do you put your call to wait() in a
> >synchronized block?
> >>
> >...
> >> try {
> >> synchronized (object) {
> >> object.wait(100L);
> >> }
> >> }
> >> catch (InterruptedException e) {
> >> ; // Oh well, at least we tried to wait...
> >> }
> >
> >I added the synchronized as suggested by Jonathan Gossage. As I
> >recall, my
> >first cut didn't have it, and it didn't work.
> >
The synchronized block is necessary because Java requires you to own the
monitor of the Object on which you are issuing the wait() call (it is a
method in Object). Synchronizing is the only way Java provides to become the
owner.
Regards
Jonathan
Personal Email
jgossage@xxxxxxxx
Business Email
jonathan@xxxxxxxxxxxxxx