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.
1. Create a package named cs520.hw6. Using this package, create the following classes.
a) Create a class named SharedResults as follows. The class keeps track of the shared result.
The instance (or member) private variable – result (int).
b) A void addToResult method 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.
c) 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__
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.
3. 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.
I am an senior Java developer and I have coped with several projects, both small and more complex ones.
I have a very strong academic background in algorithms and complexity, information systems and in software development.
I have an M.Sc. in Computer Science and I work as a telecommunications engineer in my regular job.
I have very strong analytical and researching skills, as I have a research background (I worked in a technological research center for more than 2 years).
I believe I can deliver your project in a reasonable time, after setting the exact requirements.
I am an IITK graduate, 9 year experienced software professional and I have got top notch developers in my team, who have got experience across a span of technologies. The members in my team have worked with top notch tech organization such as Amazon, Cisco, Oracle etc. We have been involved in similar projects in the past and our track record has been excellent.
I am a software engineering student at Canada's Capital University - Carleton University, and I work part-time as a software developer at University of Ottawa on a large-scale government project. I am extremely skilled in JAVA and Android and I am very passionate towards what I do. You can expect perfection and complete satisfaction from my work. I am very familiar with threads. I have recently created a TFTP File-transfer software using multi-threaded architecture. I believe I am the best candidate for this project.
Helloaa.... I am very much interested in helping people who are in need of technical solutions... My love for coding has brought me to freelancer.... I have included a sample output below... Connect with me to get the source code... Looking forward to chat with you regarding the project.
@Before -> Total Result : 0
Value of sum from start[1] to end[100] : 5050
Current thread name : Thread[Thread-0,5,main]
Adding value 5050 to result[result=5050]
Cumulative Result : 5050
Value of sum from start[101] to end[200] : 15050
Value of sum from start[201] to end[300] : 25050
Value of sum from start[301] to end[400] : 35050
Current thread name : Thread[Thread-2,5,main]
Adding value 15050 to result[result=20100]
Cumulative Result : 20100
Current thread name : Thread[Thread-6,5,main]
Adding value 35050 to result[result=55150]
Value of sum from start[401] to end[500] : 45050
Cumulative Result : 55150
Current thread name : Thread[Thread-4,5,main]
Adding value 25050 to result[result=80200]
Cumulative Result : 80200
Current thread name : Thread[Thread-8,5,main]
Adding value 45050 to result[result=125250]
Cumulative Result : 125250
@After -> Total Result : 125250
I have vast experience in the Java programming language. My knowledge and expertise in java includes
1. Thread synchronization
2. Creating Java classes and new instances.
3. Creating packages.
4. Debugging java applications and packaging into .Jar executable files.
I believe am the best candidate who will deliver the job.
I have 3+ years of experience in working with extensive code basis at industrial level.
I have quality understanding of JAVA. I have developed websites using php.
I hail from a top notch college in Inida, IIT Kharagpur.
I have worked with Barclays Capital Tech Division and Oracle India Pvt Ltd for couple of years.
The assignment u are offering is pretty straight forward. I can do it quickly.
Over the years I've realised that the reason most software development products fail is due to misunderstanding of business requirements.
I have extensive knowledge on Java and distributed development.
I've developed the code according to your requirements in about 15minutes.
Result -> 125250