Discount Get CS 520 ALL WEEKS Solution ONLY $154.91
CS520, CIS 520, CIS 520 Week 1 assignment - iLab 1 - Lab 1 - Java... [$8.99]
CS520, CIS 520, CIS 520 Week 2 assignment Part 1 - iLab 2 - Lab 2... [$11.99]
CS520, CIS 520, CIS 520 Week 2 assignment Part 2 - iLab 2 - Lab 2... [$15.99]
CS520, CIS 520, CIS 520 Week 2 assignment Part 3 - iLab 2 - Lab 2... [$19.99]
CS520, CIS 520, CIS 520 Week 3 assignment Part 1 - iLab 3 - Lab 3... [$15.99]
CS520, CIS 520, CIS 520 Week 3 assignment Part 2 - iLab 3 - Lab 3... [$19.99]
CS520, CIS 520, CIS 520 Week 4 assignment Part 1 and Part 2 - iLa... [$21.99]
CS520, CIS 520, CIS 520 Week 5 assignment - iLab 5 - Lab 5 - Java... [$19.99]
CS520, CIS 520, CIS 520 Week 6 assignment - iLab 6 - Lab 6 - Java... [$19.99]
Get Selected Weeks Solution with ONLY NOT Add Selected Tutorials To Cart
CS520, CS 520, CS 520 Week 6 assignment - iLab 6 - Lab 6 - Java Programming
    CS520, CS 520, CS 520 Week 6 assignment - iLab 6 - Lab 6 - Java Programming CS520, CS 520, CS 520 Week 6 assignment - iLab 6 - Lab 6 - Java Programming CS520, CS 520, CS 520 Week 6 assignment - iLab 6 - Lab 6 - Java Programming

CS520, CS 520, CS 520 Week 6 assignment - iLab 6 - Lab 6 - Java Programming

$19.99

CS520 Week 6 Assignment
You are strongly encouraged to add comments throughout the program. Doing so will help your facilitator to understand your programming logic and grade you more accurately.
You must work on your assignments individually. You are not allowed to copy the answers from the others. However, you are encouraged to discuss the approaches to the homework assignments with your section mates and the facilitator in your section via the discussion board.
Each assignment has a strict deadline. However, you are still allowed to submit your assignment within 2 days after the deadline with a penalty. 15% of the credit will be deducted unless you made previous arrangements with your facilitator and professor. Assignments submitted 2 days after the deadline will not be graded.
The assignment solution will be available 48 hours after the assignment deadline.
When the term lastName is referenced in an assignment, please replace it with your last name.

You are strongly encouraged to add comments into your program!

Create a new Java Project in Eclipse named HW6_lastName and complete the following requirements based on the Threads. Several threads will share a single object and contribute their individual result to the shared object. The shared object accumulates the partial results.

Create a package named cs520.hw6. Using this package, create the following classes.

 Create a class named SharedResults as follows. The class keeps track of the shared result.
The instance (or member) private variable – result (int).
A void addToResultmethod which 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.
The getResult method with no arguments which returns the shared result. Handle the synchronization issue with this method.
 

2.      Create a class named LongTask which 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 the loop, invoke the addToResult method of the shared object and provide this accumulated sum.

 

 

Create a Test class to test the following functionality in its main method.
a.Create the SharedResults object and assign it to a variable.

b.Create 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 created.

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

e.Print the result from the shared object.

     

      Sample Output:

Create an archive of your Eclipse project using the following steps. Select the HW6_lastName project in the Eclipse IDE’s Package Explorer or the Navigator window.

Click File->Export. Select the General->Archive File option. Click Next.

Specify the “To archive file:” entry as say, C:\Temp\HW6_lastName.zip.

The zip file will be created and stored in the C:\Temp folder.

Submit this zip file as an attachment in the Assignment Section of Vista.

My tutorial contains Java Programs - Eclipse Project and Document.

If you have more questions, please contact me via email support@extutorials.com

I will help you any time

Thank you !

Attached Files

Move over [ preview ] file name to preview content in it!

  • HW6_lastname.zip [6.7KB]
    • .classpath
      • .project
        • .settings
        • bin
        • src
          • cs520
            • hw6
              • LongTask.java [0.6KB] [ preview ]
              • SharedResults.java [0.3KB] [ preview ]
              • Test.java [0.7KB] [ preview ]

      Write a review

      Your Name:


      Your Review: Note: HTML is not translated!

      Rating: Bad           Good

      Enter the code in the box below:



      Tags: CS520, CS 520
      PURCHASE SAVE
      2 Tutorials 10%
      3 Tutorials 13%
      4 Tutorials 16%
      5 Tutorials 19%
      6 Tutorials 22%
      7 Tutorials 25%
      8 Tutorials 28%
      9 Tutorials 31%
      10 Tutorials 34%
      add url more

      9MZQASHWN73B