Question: Something went wrong in the following program. What fix is needed to make Thread - A and Thread - B run concurrently? public class Main

Something went wrong in the following program. What fix is needed to make
Thread-A and Thread-B run concurrently?
public class Main
{
private static class ThreadDemo extends Thread
public ThreadDemo(String name){
this.setName(name);
}
@Override
public void run(){
System.out.printIn("Running "+ this.getName());
try {
for(int i=20; i>0; i--
System.out.printIn("Thread: "+ this.getName()+","+ i);
Thread.sleep(50);
}
} catch (InterruptedException e){
System.out.printIn("Thread "+ this.getName()+" interrupted.");
}
System.out.printIn("Thread "+ this.getName()+" exiting.");
}
1
}
public static void main(String args[])
{
ThreadDemo T1= new ThreadDemo("Thread-A");
ThreadDemo T2= new ThreadDemo("Thread-B");
T1.run();
T2.run();
}
1
In the main method, calls to join are needed.
run must be public.
ThreadDemo must be public.
In the main method, calls to run should be replaced with calls to start.
In the main method, calls to run should be replaced with calls to join.
ThreadDemo needs to declare a start method.
Nothing. They already run concurrently.
Select all true statements.
An abstract method ends in a semicolon.
Abstract classes can be instantiated.
An abstract method has a header, but no body.
Interfaces can be instantiated.
A Java class can implement multiple interfaces.
 Something went wrong in the following program. What fix is needed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!