Professional Documents
Culture Documents
Generics
Generics
1 synchronised keyword I
2 Synchronised methods
I
Problem start
3 Semaphores Producer Consumer
4 Atomic Data Types
Synchronised keyword specific to java
Adder Subtractor
paint Hello
Hi
print count synchronized count
synchronized
Read count
Read want
is
x 1
x 1
count count
think like
count count lock lock
synchronised
Critical section
code
Éfgfhfhffh fÉ i
mnᵈfʰ
EL
9 Consumers shirts
If Buy
conditions
to enter the showroom if there is a
1 I only want a consumer
shirt available for
them
the showroom if there is
want to enter
2 I only a
producer
them to put their shirt
space
available for
empty spaces
that can enter the store
producers
enter the store filled spaces
consumers that can
Consumer
Produce
store size 1 0 E
if
store size1 mansize if
store remove
store.add newshirts
Infront
smario
Producer T2 Producer 2
sickman True
ifsinehmax I.de if
11 Ff critical section
queue
enter the CS
At one time only 1 person is allowed to
Because of how a lock works
Why
No
Is thisgoing to lead synchronization problem
to
It will
week
Not fast enough
Semaphores
s new semaphore
Semaphore 1
This means at mar 2
the
threads can acquire
look at 1 time
g acquire g acquire C
stoma add items store remove
5 release g release
In Semaphore
In winter
lock Semaphore
lockl s acquire 11
s release 1
unlock I
9H
If massive 7
enter because 4 shirts
4 consumers can
Semaphore
s new semaphore 14
a
THE
dET
Inum
store FIT All empty
semaphore
new semaphore
consumer that can enter 7
C 1 0
Semaphore
p 4
3 7
Semaphore
c acquired
prequire store remove
CS
store addlitem
c releaselli prelease
a Integers t locks
to think of semaphores
Try
fÉfÉ
tfhhhhhhfhtdhd
ffhfn.fm
ffÉÉiTÉÉ f
f Hra 00
HIM Coffemaphores