1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Maru [420]
3 years ago
10

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
}
}

Computers and Technology
1 answer:
lesya [120]3 years ago
6 0

Answer:

Following are the code to this question:

Counter T = new Counter(1, 100); //creating Counter class object and call its parameterized constructor        

Thread T1 = new Thread(new Runnable()  //creating Thread object T1.

{            

   public void run() //define run method

   {                

       T.countRange(); //call countRange method    

   }          

});    

Thread T2 = new Thread(new Runnable()  //creating another object "T2" of Thread.

{            

   public void run() //define run method

   {                

       T.countRange();           //call countRange method

   }      

});    

T1.start(); //start Thread T1    

T2.start(); //start Thread T2    

Explanation:

Description of the above code as follows:

  • In the given code, inside the main method the Counter class object "T" is created, that calls its parameterized constructor, which accepts two integer value that is "1 and 100".  
  • In the next step, thread class object T1 and T2, is created, which uses run method, in which it called the countRange method inside the method a for loop is declared that prints value between parameter value.  
  • In the last step, the start method is called, which uses the run method to call countRange method.  
  • For full program code please find the attachment.

You might be interested in
An ______ search is when the buyer looks for information beyond personal knowledge to help make the buying decision, such as che
victus00 [196]

Answer: External

Explanation: External search could be explained as the additional information gathered beyond an individual's personal knowledge or experience in a bit to influence the individual's decision on a particular product or topic. This additional information could include; information sought from friends and families, online or internet research on relevant site, blogs or publications.

Therefore, a buyer who asks a friend, checking the internet or visiting a showroom or make other enquiries beyond his personal knowledge in other to make buying decision is making an external search.

6 0
2 years ago
You are creating a story map about Mexico. After configuring the web app template, you launch the app to test it. When the app o
navik [9.2K]
Nbdjsksjsidjdjwkwejd
3 0
3 years ago
If you came across an article that discussed the benefits of studying the night before a test rather than the morning of, what c
Marina CMI [18]

Answer:

A. Do your own research including reading articles related to the same topic.

Explanation:

To confirm online information that is not made by reputable experts, professionals, journals, or websites, it is always recommended to cross-check such information carefully. To do that is to make research on the same topic and confirm if the actual information is the same.

Hence, in this case, the correct answer is "Do your own research including reading articles related to the same topic."

5 0
3 years ago
Sequentially prenumbered forms are an example of a(n): a. Processing control. b. Data transmission control. c. Input control. d.
Stella [2.4K]

Answer:

Sequentially pre-numbered forms are an example of a(n):

c. Input control.

Explanation:

  • Such a type of control in which keep updating data on the basis of monitoring of data is known as Processing Control. Data matching is an example of processing control.
  • Data Transmission Control is such a control in which transmission of data    is done. Parity check is an example of data transmission control.
  • Input Control is such type of control in which user can perform different tasks like adding text. Sequentially pre-numberered forms and turn around documents are an example of an input control.
  • Examples of Data entry control include batch total and validity check.

7 0
3 years ago
Explain benefits and disadvantages of using BNC over F-Type connectors on coaxial cables
Leokris [45]

Answer:

The benefits and disadvantages of using BNC over F-Type connectors on coaxial cables are;

The <em>benefits </em>of the BNC includes;

1) Easy connect and disconnect for a more rapid connection unlike the F-Type connector which is a screw connector

2) Reduction on stress on the termination of the coaxial cable

3) Appropriate in systems that see frequent reconfiguration unlike te F-Type connector that is permanently attached

4) Prevent unwanted disconnection ensuring image consistency by locking into place

5) Can extend to 300 ft.

The <em>disadvantages</em> of the BNC connectors are;

1) A separate power supply for the cable is required

2) Is used only for video transmission

3) Cannot be used for audio

4) The center wire is not easily visible like those of the F-Type connector which serves as a pin

5) The BNC connector is not watertight like the F-Type connectors

6) There are no provision for properly and securely attaching the cable to the camera for field work such that it can be easily disconnected while in use unlike the F-Type connectors

7) It is not as easy to manufacture like the F-Type connector and it is more expensive

8) The installation of the BNC connector on a coaxial cable is more intricate and the center cable is hidden from view after the BNC is attached thereby making it not possible to see if there is an error in installation which is unlike the F-type connector that takes less than 30 seconds to be attached to a cable

9) The F-Type connector provides more cost savings during installation than the BNC connector

Explanation:

The BNC connector is a type of bayonet connector used more frequently on CCTV systems. The benefits of the BNC includes;

The F-Type connectors are usable on SATV, CATV, and Digital TV where they are used together with RG6 or RG11 cables

3 0
3 years ago
Other questions:
  • Many malware attacks are ____ attacks, which involve more than one type of malware and/or more than one type of transmission met
    6·1 answer
  • Instructions: Type the correct answer in the box. Spell the word correctly.
    5·2 answers
  • If you want to emphasize the Greek root of a word in a document, which tool in Microsoft® Word could you use?
    6·2 answers
  • You have a user who takes his laptop home every day after work. When he's working in the office, the laptop must get an IP addre
    13·1 answer
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    14·2 answers
  • PLEASE HURRY I WILL GIVE BRAILIEST TO WHO EVER ANSWERS AND IS CORRECT
    14·2 answers
  • PLS HELP ILL GIVE BRAINLY- (enter the answer) Microsoft _________ is an example of a desktop publishing software
    13·2 answers
  • First let 2161965 answer<br> and then you ..
    11·2 answers
  • State five differences between Dos and Windows.​
    14·1 answer
  • In 1972, earlier designers built the
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!