🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19275

Re: Problem with static synchronized methods

#19275
From: James Rudnicki
Date: Mon, 23 Feb 1998 00:00
42 lines
1755 bytes

Frank Febbraro wrote in message <6cn593$b5f11@forums.borland.com>...
>I have a class that extends Thread.
>
>In this class there a a few static methods that are used to put a
>mutual exclusion lock on the class.
>
>I have around 5 instances of this class.
>
>Inside the first synchronized method if certain conditions do not
>exist this thread is supposed to yield() to other threads waiting on
>this class level lock.
>
>Example:
>         while(conditions are not met )
>         {
>              yield();
>         }
>
>The problem is that "yield()" never awakens the other blocked threads.
>It gets stuck and executes this loop forever.


I think you are saying you have functions:
  static synchronized void foo() {
     ...
  }

The static methods do not have a this pointer, so what do they use to block:
the Class object?  If so, no other thread would be able to enter any of the
"static synchronized" methods.  The yield() would give them a chance, but
they are locked out.

back to the drawing board time

Are you using so much static so that the five objects can share data?  Maybe
constructing a single object for the shared data and giving each a reference
would give you the synchronization control you need.

bye,
Jim
Technical Details
Message-ID: <6crdah$gbj8@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6cn593$b5f11@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,85d45b229917609
X-Google-Attributes: gidf74b3,public
From: "James Rudnicki" <rudnicki@best.com>
Subject: Re: Problem with static synchronized methods
Date: 1998/02/23
Message-ID: <6crdah$gbj8@forums.borland.com>
X-Deja-AN: 327769536
References: <6cn593$b5f11@forums.borland.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: None
Newsgroups: borland.public.jbuilder.java.language