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 18 year old female is preparing to go to college in the Fall. She received the 1st dose of HPV and her booster dose of Mening
Elenna [48]

Answer: No, you will not have to determine the exact vaccine that caused the fever and rash. The CDC will determine that information.

Explanation:

To report a vaccine reaction to VAERS you just have to list the symptoms and reactions that were caused after getting a vaccine. The form that is needed to fill out a VAERs can be found on the CDC website. The person filling out the form will need to know the who, when, where, and how of the injury or symptom.

After the form has been received the patient will be contacted and their symptoms will be monitored. Some of the most common reactions after getting a vaccine are;

  • swelling
  • pain
  • redness
  • rash

4 0
3 years ago
Now suppose that the file is broken into 5 packets, each of 10 Mbits. Ignore headers that may be added to these packets. Also ig
Vesnalui [34]

Answer:

6.025seconds

Explanation:

For each link we have,

Dtran = 10mbits/10mbps =1 second

Dprop = 5000km/2×10^8m/sec =0.025sec.

Total delay =( 5 + 2-1) + Dtran+ 2 Dprop= 6.025seconds

4 0
3 years ago
Research and discuss the similarities and differences between cloud computing and client-server computing. Discuss the pros and
harkovskaia [24]

Answer:

Cloud computing as a virtual hosting tool, is much more theoretical. Both servers, applications, and communications are hosted in the cloud, off property, rather than being available via computer machine whereas In computing client/server, a controller gets client requests mainframes and needs to share its services, programs and/or data of one sometimes more client systems on the internet, and a client would be a portable platform that specific portions with a server and make use of a finite resource.

Explanation:

<u>Similar to cloud computing and client-server computing: - </u>

  • The cloud computing and client-server networking underpinning principles are the same. That is contact between client and server.
  • Throughout networking and client-server networking, user nodes can communicate (queries) with databases that live locally or are located in many other networks.

<u>Difference between computing and client-server computing: </u><u>- </u>

Resources: -

  • In computing client-server, the corporation or association controls the tools.
  • The services are offered in cloud computing by third parties or other businesses.

<u>The purpose of cloud computing and client-server computing is different:- </u>

  • Client-server computing is targeted at use. In computation, client-server clients request a product from the cloud. The operating system runs the test, then returns it.
  • Cloud computing is a sort of system in which the IT-related services are leased to the clients as a contract.

<u>Pros and cons of Cloud Computing:- </u>

The Pros:-

  • Lower costs for business:-The cloud is saving a lot of money for a medium-sized or small enterprise.
  • Better Reliability:- A dedicated group of experts performs all programming with such a cloud computing alternative.

The Cons:-

  • Limited Control:- When a firm stores cloud data, they have very limited control of it.
  • There have been security issues. The cloud isn't too attuned for every company to position some information on even a cloud.

<u>Pros and cons of client-server computing:- </u>

The Pros:-

  • Improved data sharing:- Data stored via the normal business method and processed on a server is available over an approved connection for the intended users.
  • Security:- Database has stronger access control and methods to ensure data could only be accessed or abused by approved clients.

The Cons:-

  • Overloaded Servers:- When multiple simultaneous requests from the client are made, the server is significantly overloaded, causing congestion in traffic.
  • Impact of centralized architecture:- Because it is centralized if a vital server fails to satisfy customer requests, the client-server then lacks good network robustness.

5 0
3 years ago
Is computer a machine?
Anit [1.1K]
Yes a computer works on many smaller items like a motherboard and a powersupply etc. to work in unison to be able to handle things you want to do on it.
8 0
3 years ago
Complete each statement by choosing the correct answer from the drop-down menu.
mihalych1998 [28]

Answers for edg:

1- speaking and listening

2- nonverbal communication

3. gestures often have multiple interpretations

4. interpreting body language and behavior

Explanation: hope this helped! i just did them and they were right :)

7 0
3 years ago
Read 2 more answers
Other questions:
  • Find a, b, and c<br> A a=4 square root of 6 b= 8 square root of 2 ; c= 4 square root of 2
    12·1 answer
  • You install an M.2 SSD card in an M.2 slot on a motherboard. When you boot up your system, you discover the DVD drive no longer
    15·1 answer
  • Heavy use of computers, combined with information overload and 24/7 accessibility via technology, can lead to
    6·1 answer
  • A low concentration of market power has positive affects. A low concentration of market share has which of the following effects
    7·1 answer
  • Suppose you have a file of data of approximately 100,000 personnel records (FYI, 213 = 8192 and 214 = 16384) using Social Securi
    12·1 answer
  • Most V-type engines use two _______, one attached to each cylinder head.
    11·1 answer
  • Which icon is greater in file size? (Show your working)
    8·1 answer
  • What advantage does a circuit-switched network have over a packet-switched network? What advantages does TDM have over FDM in a
    6·1 answer
  • Can someone help me write an algorithm and a flow chart pls for question 3
    7·1 answer
  • How does accenture generate value for clients through agile and devops?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!