The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

synchronize a static method

Posted by raghuramrao on July 26, 2000 at 12:20 AM

Hello Kishori Sharma,

Thanx a lot.
I like to know one thing!
Since Static objects are class objects...,
does a static method uses same memory place
for all the objects of that class ?.
If that is the case I presume that....
in the previous senario,
all the objects of that class should wait until the
lock is released by the current thread.Am I correct !?.

thanx in advance.
raghu

> Hi
> a. Can we synchronize a static method
> Ans: Yes. You can synchronize a static method.
> b. if YES what is its effect in multi threading environment.
> Ans: If one thread is executing a static synchronized method of a class then it holds a lock on all other syncronized methods of that class and in effect no other thread can call any of the synchonized static methods of that class untill this current thread releases the lock.
> c. if NO why
> Ans: ---

>
> Thanx
> Kishori






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us