Junior — Middle
Describe your experience using coroutines in projects
sobes.tech AI
Answer from AI
In Java, a thread can be in the following main states, defined by the Thread.State enum:
- NEW: The thread has been created but not yet started.
- RUNNABLE: The thread is executing in the JVM but may be waiting for CPU time. Includes Running and Ready states.
- BLOCKED: The thread is blocked, waiting to acquire a monitor lock to enter a synchronized block or method, or re-enter it.
- WAITING: The thread is waiting for another thread to perform a specific action without a timeout. For example, calling
Object.wait(),Thread.join()without timeout, orLockSupport.park(). - TIMED_WAITING: The thread is waiting for another thread to perform an action within a specified time. For example, calling
Thread.sleep(),Object.wait()with timeout,Thread.join()with timeout,LockSupport.parkNanos()orparkUntil(). - TERMINATED: The thread has finished execution.
You can get the thread's state using the thread.getState() method.