Question: Question 2 (25 points) In the context of Java concurrent programming using the basic threading API: (a) (10 pts.) Consider the three methods in class

 Question 2 (25 points) In the context of Java concurrent programming

Question 2 (25 points) In the context of Java concurrent programming using the basic threading API: (a) (10 pts.) Consider the three methods in class Thread used to handle thread interruptions (all are public): void interrupt(); static boolean interrupted();| boolean is Interrupted(); Describe the crucial differences between these three methods and their effect on the running thread(s). (b) (5 pts.) Fill in the three gaps marked with ... in the following code with appropriate methods from the Java threading API to achieve the effect described in the comments: public static void main(String[] args) { Thread my = new MyThread(); my.start(); while(true) { System.in.read(); if (c == -1 || c == 'X') { // (1) put the "my" thread up for termination // (2) wait for "my" thread termination break; } int c = } } class MyThread extends Thread { public void run() { while(...) // (3) should I keep running? System.out.println("I_jam running!"); } } (c) (5 pts.) When a Java thread is stuck in the call to the wait() method on some object o, what are the two events that can allow the thread to get out of it and continue its execution? (d) (5 pts.) What will a repetitive call to method start() on a Tread object result in? For example: Thread my = new MyThread(); my.start(); my.join(); my.start()

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!