https://github.com/openmohan/javaclassobjectlocks
https://github.com/openmohan/javaclassobjectlocks
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/openmohan/javaclassobjectlocks
- Owner: openmohan
- Created: 2016-12-19T05:11:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-19T06:05:28.000Z (over 9 years ago)
- Last Synced: 2025-02-01T18:16:14.186Z (over 1 year ago)
- Language: Java
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JavaClassObjectLocks
#Class Level Lock
Class level locking prevents multiple threads to enter in synchronized block in any of all available instances on runtime. This means if in runtime there are 100 instances of DemoClass, then only one thread will be able to execute demoMethod() in any one of instance at a time, and all other instances will be locked for other threads. This should always be done to make static data thread safe.
#Object Level Lock
Object level locking is mechanism when you want to synchronize a non-static method or non-static code block such that only one thread will be able to execute the code block on given instance of the class