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

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 00:30
Which boolean operator enables you to exclude a search term? a} not b} and c} or d} plus
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
1. which of these is not true about torsion bars? a. they can be used to adjust ride height b. they can be adjusted anytime since they don't affect alignment angles c. they attach between the frame and the lower control arm d. they twist to produce a spring effect
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
7.23 main lab 7 - online shopping cart background this main lab extends the earlier prep lab "online shopping cart part 1". (you should save this as a separate project from the earlier prep lab). you will create an on-line shopping cart like you might use for your on-line purchases. the goal is to become comfortable with setting up classes and using objects. requirements this lab can be done individually or as pair programming. expanded itemtopurchase class (15 points) extend the itemtopurchase class as follows. we will not do unit testing in this lab so we will not be giving you the names of the member functions. create good ones on your own. create a parameterized constructor to assign item name, item description, item price, and item quantity (default values of "none" for name and description, and 0 for price and quantity). additional public member functions set an item description get an item description print the cost of an item - outputs the item name followed by the quantity, price, and subtotal (see example) print the description of an item - outputs the item name and description (see example) additional private data members a string for the description of the item. example output of the function which prints the cost of an item: bottled water 10 @ $1.50 = $15.00 example output of the function which prints the item description:
Answers: 1
question
Computers and Technology, 25.06.2019 08:40
Which of the following statements is incorrect in relation to processes: while, strictly speaking, at any instant of time, the cpu is running only one process, in the course of 1 second, it may work on several of them, giving the illusion of parallelism a process is just an instance of an executing program, including the current values of the program counter, registers, and variables processes can be created when an operating system is booted, created by the user, or a running process can create children processes there is a master process, which when started can last forever, and is not killable
Answers: 3
You know the right answer?
I have a class named Counter. In this class I have a synchronized method called countRange(). This m...
Questions
question
Spanish, 28.07.2019 20:30