Forums Register Login

Synchronized Static Method

+Pie Number of slices to send: Send
I am confused by synchronized on static method,just like this:

My question is:
Does the object pool synchronize???
In my mind,synchronized on method

is the same as

But in static method,the keyword "this" is not allowed.So,what exactly "synchronized static method()" mean???
+Pie Number of slices to send: Send
When you synchronize on a static method you are placing a lock on the class for the duration of the static method.
-Barry
+Pie Number of slices to send: Send
Hi
Visit this link
http://www.javaworld.com/javaworld/jw-04-1999/jw-04-toolbox.html
read critical section in java Threads.
I think this will certainly help you solve your problem.
Cheers,
Santosh Terkhedkar.
+Pie Number of slices to send: Send
synchronizing a static method locks on the java.lang.Class object representing the class, for instance in:

is the same as
+Pie Number of slices to send: Send
When a class or interface is loaded a java.lang.Class instance is created to represent it. You can access references to them via the Class literals
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 995 times.
Similar Threads
Exam 9, Q24 Dan Chisholm
StringBufferPool (why not Threadsafe) ?
Vector performance
n-dimensioned array in Java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:15:48.