Skip to content
Advertisement

Tag: synchronization

Synchronization with static block

I have a question: can we use the static keyword with a synchronized method? As we all know that static is related to class and synchronization is used to block an object, using synchronized with static doesn’t make any sense to me. So why and in which situation would I use synchronization with the static keyword? Answer I think this

Java synchronization between different JVMs

The project I am working on would trigger various asynchronous jobs to do some work. As I look into it more these asynchronous jobs are actually being run as separate JVMs (separate java processes). Does it mean I would not be able to use any of the following if I need to synchronize between these processes: synchronized methods/blocks any lock

Thread Safe Singletons in Java

The wikipedia article on Singletons mentions a few thread safe ways to implement the structure in Java. For my questions, let’s consider Singletons that have lengthy initialization procedures and are acccessed by many threads at once. Firstly, is this unmentioned method thread-safe, and if so, what does it synchronize on? Secondly, why is the following implementation thread safe AND lazy

Advertisement