aspose file tools*
The moose likes Threads and Synchronization and the fly likes static synchronized method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "static synchronized method " Watch "static synchronized method " New topic

static synchronized method

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368

static synchronized int sumTotal() {


int getSalary() {


If two threads are trying to access sumTotal() at the same time, Whether Thread2 gets locked until Thread1 releases lock ?

Henry Wong

Joined: Sep 28, 2004
Posts: 18139

You have been asking a lot of simple thread questions lately. This is *not* the best way to learn threads, as threads is not just about the API.

For this question, why don't you tell us, what is it that you are confused with? And quite frankly, maybe it would be a good idea to start with the Sun tutorial on threads.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
public class Test implements Runnable {

public void run() {
Thread T1 = new Thread();
Thread T2 = new Thread();
Thread T3 = new Thread();
Thread T4 = new Thread();
Thread T5 = new Thread();


synchronized static int methA() {


synchronized int methB() {


static int methC() {


int methD() {


synchronized int methE() {



Using different threads(Thread1, Thread2, thread3, Thread4, Thread5) for each methods. Whether except Thread5, all other Threads run concurrently?

I agree. Here's the link:
subject: static synchronized method
Similar Threads
tell me the differnce
What is the difference between these methods?
Abstract class??
static synchronized block
Can you synchronize an array?