Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago