Linked Questions

2 votes
4 answers
9k views

Java Static Synchronized [duplicate]

Possible Duplicate: How do synchronized static methods work in Java? Can someone make me understand the fundamental difference between the following two functions: public static void ...
randon's user avatar
  • 95
6 votes
1 answer
1k views

What does synchronized on a static method do? [duplicate]

Possible Duplicate: How do synchronized static methods work in Java? I was wondering what would happen if synchronized was used on a static method. Does the class get a lock on that method? How ...
blaa's user avatar
  • 63
1 vote
2 answers
165 views

How java synchronized work [duplicate]

If class A has two synchronized methods, say, methodA and methodB. If one thread is accessing methodA, can another thread access methodB? According to my understanding, when accessing methodA, the ...
user1801838's user avatar
150 votes
8 answers
102k views

Java synchronized static methods: lock on object or class

The Java documentation says: it is not possible for two invocations of synchronized methods on the same object to interleave. What does this mean for a static method? Since a static method has no ...
jbu's user avatar
  • 16.1k
7 votes
3 answers
52k views

Write to text file from multiple threads? [duplicate]

i have 20 threads that write with the println() function on a file called results.txt. How can i synchronize them all? I note every time my program run i have different number of lines of text in ...
Marco Micheli's user avatar
14 votes
5 answers
27k views

Multi-Threading on different instances of same object in Java

I've learned that every class byte code is been loaded to the memory once for each class loader, thus when a thread is executing the byte code of some method, and another thread comes along? 1 thread ...
TacB0sS's user avatar
  • 10.2k
1 vote
4 answers
8k views

Synchronized keyword and static classes in java

I was reading a threading tutorial that’s originally from (I believe) the IBM developerworks site. In it they talked about the synchronized keyword and how a synchronized block of code is locked by ...
larryq's user avatar
  • 16k
0 votes
1 answer
2k views

Java Thread lock on static method

As per my knowledge in Java class with Non static synchronize method : lock acquire on particular object Static synchronize method : lock acquire on class I am little bit confuse with this, since we ...
Rakesh Soni's user avatar
  • 10.7k
5 votes
3 answers
3k views

What are class level, object level, explicit and intrinsic locking?

I have been going through Java multi-threading concepts. The more I go through them, the more confused I become. Right now I am not understanding the differences between class level, object level, ...
The Dark Knight's user avatar
0 votes
4 answers
482 views

Is static method without any parameters thread-safe?

I have a counter and multiple threads access the getCount method. The code is like the following: public class ThreadSafeMethod { public static int counter = 0; public static int ...
Ryan's user avatar
  • 2,855
-2 votes
1 answer
843 views

In java can we declare main method as:- final synchronized strictfp

In can we declare main method as: final synchronized strictfp what is the meaning of the main method written above ? final synchronized strictfp public static void main(String []args){}
Vaibhavbuccha's user avatar
2 votes
4 answers
417 views

synchronizing static methods in the same class

I have a class like this: public class Utils { public static void doSomething() { // doSomething code } public static void doSomethingElse() { // doSomethingElse code ...
CodeClimber's user avatar
  • 4,624
1 vote
4 answers
400 views

Thread Acquired level

I am not clear the concept of Java Thread acquires an object level lock when it enters into an instance synchronized java method and acquires a class level lock when it enters into static ...
peter's user avatar
  • 8,383
2 votes
3 answers
144 views

How can class method access be safely controlled in a C++ mutli threaded program using boost?

I want to translate some Java code into C++. One of the Java classes extends the Thread class and contains the following method: public static synchronized String createUniqueID() { //some code ...
sufyan siddique's user avatar
-4 votes
1 answer
246 views

Please Explain How Java synchronized work with static method? [duplicate]

Possible Duplicate: Java synchronized methods: lock on object or class Please Explain How Java synchronized work with static method ? Some one has said that it is done by its Class Object but ...
Harsha's user avatar
  • 216

15 30 50 per page