Skip to content

OOP2018/threads-Michele5291

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Threads and Synchronization

This lab illustrates the problem of synchronization when many threads are operating on a shared object. The general issue is called "thread safety", and it is a major cause of errors in computer software.

Assignment

To the problems on the lab sheet and record your answers here.

  1. Record average run times.
  2. Write your explanation of the results. Use good English and proper grammar. Also use good Markdown formatting.

ThreadCount run times

These are the average runtime using 3 or more runs of the application. The Counter class is the object being shared by the threads. The threads use the counter to add and subtract values.

Counter class Limit Runtime (sec)
Unsynchronized counter
Using ReentrantLock
Syncronized method
AtomicLong for total

1. Using unsynchronized counter object

answer the questions (1.1 - 1.3)

2. Implications for Multi-threaded Applications

How might this affect real applications?

3. Counter with ReentrantLock

answer questions 3.1 - 3.4

4. Counter with synchronized method

answer question 4

5. Counter with AtomicLong

answer question 5

6. Analysis of Results

answer question 6

7. Using Many Threads (optional)

About

threads-Michele5291 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages