Questions and coding challenges
In this section, we will cover 20 concurrency questions and coding challenges that are very popular in interviews.
You should be aware that Java concurrency is a wide and complex topic that needs to be covered in great detail by any Java developer. Having fundamental insights about Java concurrency should be enough to pass a general Java language interview, but it is not enough for specific interviews (for example, if you apply for a job that will imply developing a concurrency API, then you must deep dive into this topic and learn advanced concepts – most probably, the interview will be concurrency-centric).
Coding challenge 1 – Thread life cycle states
Problem: Enumerate and explain, in a few sentences, the states of a Java Thread
.
Solution: The states of a Java thread are available via the Thread.State
enumeration. The possible states of a Java thread can be seen in the following diagram: