Question: Exercise 1 : public class TwoThread extends Thread { public void run ( ) { for ( int i = 0 ; i < 2
Exercise :
public class TwoThread extends Thread
public void run
for int i ; i ; i
System.out.printlnThreadcurrentThread getName;
public static void mainString args
TwoThread T new TwoThread;
Tstart;
for int i ; i ; i
System.out.printlnMain thread";
What is it doing this program
Compile and execute the program
Note: starting a thread is done via the start method. The main method is itself in a thread the main thread
Modify the previous program so that: create others threads T and T using the class
Thread and TwoThread. Execute the program and explain what you see
Modify the previous program so that the thread T complete its execution by blocking
all others thread after that they can run.
Note: you can use join method. The join method is used to hold the execution of currently running thread
until the specified thread is deadfinished execution
Exercise : Write in java a program that uses two threads in parallel:
the first will display the letters of the alphabet;
the second will display numbers from to
the second thread must wait ms after it e
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
