In Java, volatile
and synchronized
allow multiple threads to work together. But, if you use multiple threads on a single-core system, it means it's not really multithreaded, the OS just changes from one thread to another thread.
So, I think it is not necessary to use thread-safe techniques such as volatile
or synchronized
.
Is this correct?
Synchronization is independent of how many cores. It is based on how many threads competing for shared resource. When more than one thread competing you need Synchronization.