Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static synchronized method

 
kri shan
Ranch Hand
Posts: 1478
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Marshal
Pie
Posts: 21498
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
kri shan
Ranch Hand
Posts: 1478
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic