Top "Synchronized" questions

A block or method is said to be 'synchronized' if entry to it is controlled by the Java `synchronized` keyword.

Is ConcurrentHashMap totally safe?

this is a passage from JavaDoc regarding ConcurrentHashMap. It says retrieval operations generally do not block, so may overlap with …

java multithreading synchronized java.util.concurrent
synchronized block - lock more than one object

I'm modelling a game where multiple players (threads) move at the same time. The information of where a player is …

java multithreading locking synchronized
Synchronizing on String objects in Java

I have a webapp that I am in the middle of doing some load/performance testing on, particularily on a …

java multithreading synchronization thread-safety synchronized
In Java critical sections, what should I synchronize on?

In Java, the idiomatic way to declare critical sections in the code is the following: private void doSomething() { // thread-safe code …

java multithreading synchronized
What is the difference between a synchronized method and synchronized block in Java?

What is the difference between a synchronized method and synchronized block in Java ? I have been searching the answer on …

java multithreading synchronization synchronized synchronized-block
Java Synchronized Block for .class

What does this java code mean? Will it gain lock on all objects of MyClass? synchronized(MyClass.class) { //is all …

java multithreading synchronization locking synchronized
Is HttpSession thread safe, are set/get Attribute thread safe operations?

Also, does the object that is being set have to be thread safe in order to guarantee that we know …

java session thread-safety synchronized
Should you synchronize the run method? Why or why not?

I have always thought that synchronizing the run method in a java class which implements Runnable is redundant. I am …

java multithreading synchronization synchronized runnable
Learning Java, use of synchronized keyword

so i was testing with synchronized keyword. Here is an example that I tried: public class MyTest { static int i = 0; …

java synchronized
What is the difference between synchronized on lockObject and using this as the lock?

I know the difference between synchronized method and synchronized block but I am not sure about the synchronized block part. …

java concurrency locking synchronized synchronized-block