



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




1
2
3
4
5
6
7
Account object is shared mutable state.
8
9
x=1 if (x==0)
Thread A: Thread B:
true-part
10
if (instance==null) instance = new …
Thread A: Thread B:
The two callers (in thread A and thread B) will receive different instances although there should be only one instance!
if (instance==null) instance = new …
11
A reference to an object
12
19
20
21
22
E.g., Set seen = Collections.synchronizedSet(new HashSet());
23
24
25
26
27
e.g., Executor e = …^ A^ B^ C e.execute(t1); e.execute(t2); e.execute(t3); e.execute(t4); e.execute(t5); e.execute(t6);
time
t t t t4 t
t
task submission
task execution 28
29
30