The concepts of processes and threads are operating system concepts, so you may need to read the university book On Operating System Principles to understand what processes and threads are.

Simply put, processes and threads involve CPU usage and memory allocation.

Can imagine your browser, if you open a browser, said you start a process, if you open multiple tabs again, said you started the different threads (browser on the blackboard: start the different tabs, actually start is a different process, not start a thread, but this pattern is more easy to understand it).

Java is multithreaded, which means that different threads can be started for different computations within the JVM to speed up processing.

Think of the browser example. You open a web page, wait for a while, feel slow to load, and go to another web page.

Whenever threads are involved there are memory sharing issues, and if there are memory contributions there are thread safety and thread synchronization issues.

Since there are thread safety and synchronization issues, how to understand and solve?

These are the reasons why you are often asked in job interviews.

www.ossez.com/t/java/1369…