subject

I have a class named Counter. In this class I have a synchronized method called countRange(). This method prints out a count in the range from the minimum to the maximum values stored by the Counter class attributes. Please implement the body of the main() method in Test class to instantiate and start two threads that invoke countRange() method. You can use either named or anonymous Thread instances. Don't forget to make a call to start() method in each thread. What I am asking you to do is similar to what Stopwatch examples in the "Multi-threading and concurrent programming" lecture module showed.
Please only include the code inside the main() method into your answer.
Below is the implementation of Counter class and the shell of the main() method in Test class:
import java. lang.*;
class Counter {
private int min;
private int max;
Counter(int min, int max){
this. min = min;
this. max = max;
}
synchronized public void countRange() {
for(int i = this. min; i <= this. max; i++){
System. out. println(i);
}
}
}
public class Test {
public static void main(String[]args) {
// your implementation goes here
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 20:50, rrrrainy
What are the advantages of google cloud ?
Answers: 2
image
Computers and Technology, 22.06.2019 06:00, Wolfie215
Which of the following is a way that advancements in technology improve humans' ability to measure air quality and protect human health? a. air quality data gathered by new instruments can be used to reduce exposure to pollutants. b. new technologies enable natural and human-made pollution sources to be located and monitored. c. air quality data gathered by new instruments can be used to predict trends in pollution over time. d. new technologies allow governments to make informed decisions about the regulation of pollution. (choose more than one)
Answers: 2
image
Computers and Technology, 22.06.2019 14:30, chaparro0512
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
image
Computers and Technology, 23.06.2019 07:00, sugaree95
What are three software programs for mobile computing?
Answers: 1
You know the right answer?
I have a class named Counter. In this class I have a synchronized method called countRange(). This m...

Questions in other subjects:

Konu
Biology, 19.09.2019 21:30
Konu
Mathematics, 19.09.2019 21:30