Skip to content

Commit 908c092

Browse files
Update README.md
1 parent e675824 commit 908c092

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
11
# ConcurrentProgrammingWithJavaThreads
22
Concurrent Programming with Java Threads. The project imitates the scenario of a company containing 10 departments, making transactions over 50 of its internal accounts.
3+
4+
# Assignment problem Statement
5+
I was supposed to develop a thread-based Java Program, capable of executing on multiple cores, for the following scenario.
6+
7+
A company wishes to implement a simple accounting system that allows each of its 10 departments to perform the following transactions on its 50 internal accounts.
8+
9+
1. Deposit an amount into a named account.
10+
2. Withdraw an amount from a named account.
11+
3. Transfer an amount between named accounts.
12+
13+
The application must allow for the concurrent transfer between different pairs of accounts when possible. The application must be:
14+
15+
1. correct,
16+
2. fair,
17+
3. have no deadlock, and
18+
4. not have any individual thread "starved".
19+
20+
Application should be able to handle at least 10,000 transactions efficiently.
21+
22+
# Solution and Justification
23+
24+
1. Absence of thread starvation and fairness
25+
One can confidently say that a program doesn’t starve / choke its threads if the threads
26+
are well managed. In my program, I have used the ExecutorService and Executors
27+
interface which manages the threads created fair and square. It queues the tasks that are
28+
yet to be executed until at least one of its threads become free. The thread that becomes
29+
free first takes up the next task in the queue. This ensures absence of thread starvation
30+
and fairness.
31+
32+
2. Absence of deadlocks
33+
I have used synchronized methods to ensure that there is no deadlocks. Upon arrival of
34+
a critical section, synchronized methods helps a thread access the shared resources of a
35+
critical section, synchronously, ensuring other threads don’t gain access to the critical
36+
section until the first thread leaves the said critical section. This way, there will never be
37+
a situation when two or more threads block each other.
38+
39+
3. Correctness
40+
We can say that a program is correct if it is free of both dead locks and thread starvation.
41+
Through points 1 and 2, I can also conclude that my program is correct.
42+
43+
4. Application works efficiently to loads even higher than 10,000 transactions. While
44+
testing, i have seen upto 20,000 transactions.
45+
46+
# Detailed Report
47+
48+
A detailed report along with test cases and screenshots is provided in the repo.

0 commit comments

Comments
 (0)