Explain the term thread safety and synchronization.Thread safety:
- It is a computer programming concept.
- The term Thread safety means each method in a multi-threaded environment doesn’t access data by multiple threads at the same time.
- It allows code to run in multi-threaded environments.
- It can be used wrapper classes from java.util.concurrent.atomic.package.
Synchronization:
- Synchronization is the way to provide a secured environment and thus ensure Thread Safety.
- It is working on locking and unlocking resources.
- Synchronized keyword cannot be used for constructors and variables.
|