You are on page 1of 2

09 Hands-on Activity 1 - ARG

• Instructions

Instructions
A thread can be in one of the following states:

State Description

NEW A thread that has not yet started is in this state.

RUNNABLE A thread executing in the Java virtual machine is in this state.

BLOCKED A thread that is blocked waiting for a monitor lock is in this state.

WAITING A thread that is waiting indefinitely for another thread to perform a particular action is i

TIMED_WAITING A thread that is waiting for another thread to perform an action for up to a specified wai

TERMINATED A thread that has exited is in this state.

Create two (2) threads named by the user. Display their


various states using getState( ).
In the main method:
1. Enable user input.
2. Create two (2) threads.
3. Ask the user to enter a name for each thread.
4. Show the names and states of the threads.
5. Start the threads.
6. Have the threads sleep for half a second.
7. Show the names and states of the threads.
This study source was downloaded by 100000867853096 from CourseHero.com on 06-01-2023 21:44:15 GMT -05:00

https://www.coursehero.com/file/154054904/Create-two-2-threads-named-by-the-user-Display-their-various-states-using-getState-AESEIAH-CO/
In the run( ) method, show the name and state of the current
thread.

AESEIAH I. CONCEPCION
BSIT – 202

This study source was downloaded by 100000867853096 from CourseHero.com on 06-01-2023 21:44:15 GMT -05:00

https://www.coursehero.com/file/154054904/Create-two-2-threads-named-by-the-user-Display-their-various-states-using-getState-AESEIAH-CO/
Powered by TCPDF (www.tcpdf.org)

You might also like