Questiongenerate a new java project in eclipse and complete

Assignment Help Computer Engineering
Reference no: EM13349414

Question

Generate a new Java Project in Eclipse and complete following requirements based on the Threads. Some threads will share a single object and contribute their individual result to shared object. The shared object accumulates partial results. Make a package named cs520.hw6. Using this package, produce the following classes.

1. Generate a class named SharedResults as follows. The class keeps track of shared result.

a. The instance (or member) private variable result (int).

b. A void addToResult process that takes the given integer argument and adds it to the shared result. This method then prints to the console the name of the current thread, the value it added, and the cumulative result. Handle the synchronization issue with this method.

c. The getResult method with no arguments which returns the shared result. Handle synchronization issue with this method.

2. Generate a class named LongTask that extends the Thread class.

a. The instance (or member) private variables sharedData (of type SharedResults), start (integer) and end (integer).

b. A single constructor which takes the above three arguments and stores them in the instance values. Also, create a name for this thread as Thread_<start>_<end>

c. In the run method, add the integer numbers from start to end (both inclusive) using a for loop. Also, sleep for a random time (up to 10 milliseconds) in each iteration of the loop. After loop, invoke the addToResult technique of shared object and provide this accumulated sum.

3. Produce a Test class to test following functionality in its key method.

a. make the SharedResults object and assign it to a variable.

b. generate five LongTask objects by passing the above shared object and the start and end values for each as (1, 100), (101, 200), (201, 300), (301, 400), and (401, 500) respectively.

c. Start each thread as it is formed.

d. Wait for all the threads to complete using joins method.

e. Print result from the shared object.

Reference no: EM13349414

Questions Cloud

Questionuse the following system printprimes for questions : questionuse the following system printprimes for questions a-f below.a illustrate the control flow graph for the
Questionstrayer university provides each student with a : questionstrayer university provides each student with a login id to a university maintained oracle database server for
Question arnold benedict is thinking of purchasing an : question arnold benedict is thinking of purchasing an apartment complex that is offered for sale by the firm of flee
Question millar inc purchased a truck to use for deliveries : question millar inc. purchased a truck to use for deliveries and is attempting to evaluate how much depreciation
Questiongenerate a new java project in eclipse and complete : questiongenerate a new java project in eclipse and complete following requirements based on the threads. some threads
Question dasher company acquired a truck for use in its : question dasher company acquired a truck for use in its business for 25500 in a cash transaction. the truck is expected
Question 1scenariojohn is responsible of an significant : question 1scenariojohn is responsible of an significant unit of your ministry. he has the leaning of taking unilateral
Question during the existing year airport auto rentals : question during the existing year airport auto rentals purchased 60 new automobiles at the cost of 14000 per car. the
Question juan luan social security number 454-11-7000 is a : question juan luan social security number 454-11-7000 is a single taxpayer and is employed as an administrative help at

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a program to apply combination of transformation

Write a program to apply combination of transformation, rotation, reflection and shearing) on the following objects.

  Give the reasons based on real life programming scenarios

The two most important design issues that are specific to character string types are the following: Should strings be simply a special type of character array or a primitive type.

  Write down an expression that evaluates to true

Given variables isFullTimeStudent and age , write an expression that evaluates to true if age is less than 19 or isFullTimeStudent is true.

  Determine a symbolic equation that represents the amount

Suppose that water is being pumped into an initially empty tank. It is known that the rate of the flow of water into the tank at time t (in seconds) is 50-t liters/s.

  Make use to effectively manage a team of system

Are different management techniques needed for managing technical personnel versus nontechnical personnel.

  What is the key for table t

What is the highest normal form for table T explain.

  Difference between a java compiler and a java interpreter

expalin the difference between a Java compiler and a Java interpreter.

  What are some automation tools

What is the office automation and group collaboration software which is used in any oraginization? How do you analize this/ what are the ad/disadvantages on this method.

  How many rtts would take this tcp connection to transmit

How many RTTs would take this connection to transmit a 100-packet sized file, just by using TCP AIMD mechanism, when no packets are lost during the transfer? (Assume slow-start is not used)

  Modify a purchased software package

If the project team find out that the best alternative is to modify a purchased software package, then the team has several options to consider. What are they? What mus the project team take responsibility for in each case?

  Create the logic for a program that continuously prompts

The application passes the value in turn to a method that computes the sum of all the whole numbers from 1 up to and including the entered number, and to a method that computes the product of all the whole numbers up to and including the entered n..

  What occurs in an infinite loop

What occurs in an infinite loop? Create your own Repeat-until repetition arrangement.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd