The purpose of this lab is to create three threads and run them at the same time. While are running they will be printing out their name in the console. By observing what is printed in the console, you can observe how the threads run and in which order.
- Create a class called PrintMe which implements Runnable.
In the run method, loop 10 times: print the name of the current thread and then sleep for 2 seconds. - Create a program called TestThreeThreads.
- In the main, create an instance of PrintMe.
- Create three threads using the PrintMe object.
- Name each thread using the setName method.
- Start each thread.
- Compile and run the TestThreeThreads program.