Java Multithreading Several Threads Share Single Object Contribute Individual Result Share Q37246861

Java Multithreading

Several threads will share a single object and contribute theirindividual result to the shared object. The shared objectaccumulates the partial results.
Create a class named SharedResults as follows. The class keepstrack of the shared result. a. The instance (or member) privatevariable – result (int). b. A void addToResult method which takesthe given integer argument and adds it to the shared result. Thismethod then prints to the console the name of the current thread,the value it added, and the cumulative result. Handle thesynchronization issue with this method. c. The getResult methodwith no arguments which returns the shared result. Handle thesynchronization issue

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.