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
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "static synchronized method " Watch "static synchronized method " New topic
Author

static synchronized method

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1379

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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40


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.

http://java.sun.com/docs/books/tutorial/essential/concurrency/

Henry


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

Joined: Apr 08, 2004
Posts: 1379
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?




 
 
subject: static synchronized method