Generate a new java project in eclipse

Assignment Help Computer Engineering
Reference no: EM133365

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: EM133365

Questions Cloud

Illustrate the control flow graph : Illustrate the control flow graph
Clarify security mechanisms available for a database : Clarify security mechanisms available for a database
Prepare a seven - year forecast of net operating income : Prepare a seven - year forecast of net operating income for the Sated Satyr Apartments
Evaluate the amount of depreciation expense : Evaluate the amount of depreciation expense that can be recognized under each of the subsequent depreciation methods in the first and second years of the truck's useful life.
Generate a new java project in eclipse : Generate a new Java Project in Eclipse
Evaluate the amount of depreciation : Evaluate the amount of depreciation that can be taken in the first two years of the truck's useful life if the actual miles driven are 16,000 and 18,200, correspondingly.
Training and development : job training, role of HR in Modern Management, method of staffing, job report exercise
Evaluate the amount of depreciation : Evaluate the amount of depreciation to be recognized for each mile that a rental automobile is driven.
Evaluate the income tax return for the current year : He has the subsequent items pertaining to his income tax return for the present year

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write down program that models an employee

Write down program that models an employee

  Describe the mechanics of Buffer overflows

Prepare a complete tutorial, including an analogy to describe the mechanics and a graphic to support your analogy, on one of the subsequent areas

  Define role of customer and end-user on an agile process

Define role of customer and end-user on an agile process

  Develop a checkout lane simulation

Develop a checkout lane simulation that can be used to determine the optimal number of lanes that Cougar Mart should have open.

  Explain how an enterprise would use 3g, 4g and wwan

Explain how an enterprise would use 3G, 4G and WWAN Use at least three quality resources in this project.

  Briefly describe the concept of queues

Briefly describe the concept of queues.

  Write down an application that reads 3 integers

Write down an application that reads 3 integers

  Generate a database for the gps law firm

Generate a database for the GPS Law firm

  How to set a rule that used by snort to detect an ack scan

How to set a rule that used by snort to detect an ACK scan What do you think Bro can do a better job detecting an ACK scan?

  Utilize server manager to install dns role

Utilize Server Manager to install DNS role

  Create an employee class with enough numbers

Create an Employee class with enough numbers.

  Identify and classify the it infrastructure components

Identify core and side business activities of UPS and explain how same are driven by technology, Identify and classify the IT infrastructure components available at UPS and its subsidiaries

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