[Solved] Java Multithreading basic questions


Yes Threads would be executing the same piece of code but if your code contains shared class level variables then it needs to be properly synchronised so that the each thread reads a consistent state of variables.

Threading is to ensure concurrent access to a piece of code via multiple threads.

There are different ways to achieve thread safety. You can refer java concurrency is practice for more details.

solved Java Multithreading basic questions