You should implement four threads in Java. The execution should be in this order: Thread 2, Thread 3 and finally Thread 1. Thread 0 Used to call other threads You have to use join() method Thread 1 Should be implemented using extends Thread Thread class (extends Thread) You have to use for loop Priority Max Thread 2 Should be implemented using Runnable interface You have to use for loop You have to use sleep() method (one second interval inside the loop) Priority Normal Thread 3 Should be implemented using extends Thread Thread class (extends Thread) You have to use for loop You have to use sleep() method (4 seconds interval before the previous thread) Thread Priority 7 The output should be as following: 1 Thread 2 (University number) 2 Thread 2 (University number) 3 Thread 2 (University number) 4 Thread 2 (University number) 1 Thread 3 (University number, Thread Priority) 2 Thread 3 (University number, Thread Priority) 3 Thread 3 (University number, Thread Priority) 4 Thread 3 (University number, Thread Priority) 1 Thread 1 (University number, Thread Priority) 2 Thread 1 (University number, Thread Priority) 3 Thread 1 (University number, Thread Priority)
URGENT URGENT URGENT !!!
You should implement four threads in Java. The execution should be in this order: Thread 2, Thread 3 and finally Thread 1.
Thread 0
- Used to call other threads
- You have to use join() method
Thread 1
- Should be implemented using extends Thread
- Thread class (extends Thread)
- You have to use for loop
- Priority Max
Thread 2
- Should be implemented using Runnable interface
- You have to use for loop
- You have to use sleep() method (one second interval inside the loop)
- Priority Normal
Thread 3
Should be implemented using extends Thread
- Thread class (extends Thread)
- You have to use for loop
- You have to use sleep() method (4 seconds interval before the previous thread)
- Thread Priority 7
The output should be as following:
1 Thread 2 (University number)
2 Thread 2 (University number)
3 Thread 2 (University number)
4 Thread 2 (University number)
1 Thread 3 (University number, Thread Priority)
2 Thread 3 (University number, Thread Priority)
3 Thread 3 (University number, Thread Priority)
4 Thread 3 (University number, Thread Priority)
1 Thread 1 (University number, Thread Priority)
2 Thread 1 (University number, Thread Priority)
3 Thread 1 (University number, Thread Priority)
Note: You should replace “University number” with your university number. Also, you should replace Thread Priority with that thread priority using the suitable method to get it, for example:
Failure to do the aforementioned will results on deducting marks.
1 Thread 3 (435101927, 7)
2 Thread 3 (435101927, 7)
3 Thread 3 (435101927, 7)
4 Thread 3 (435101927, 7)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps