Skip to content

Commit a2a7b53

Browse files
author
Bruce Eckel
committed
Cleanup and fixes
1 parent 45d4e5d commit a2a7b53

File tree

6 files changed

+14
-58
lines changed

6 files changed

+14
-58
lines changed

lowlevel/Atomicity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@ public class Atomicity {
1616
public Atomicity();
1717
Code:
1818
0: aload_0
19-
1: invokespecial #1 // Method
19+
1: invokespecial #1 // Method
2020
java/lang/Object."<init>":()V
2121
4: return
2222
void f1();
2323
Code:
2424
0: aload_0
2525
1: dup
26-
2: getfield #2 // Field i:I
26+
2: getfield #2 // Field i:I
2727
5: iconst_1
2828
6: iadd
29-
7: putfield #2 // Field i:I
29+
7: putfield #2 // Field i:I
3030
10: return
3131
void f2();
3232
Code:
3333
0: aload_0
3434
1: dup
35-
2: getfield #2 // Field i:I
35+
2: getfield #2 // Field i:I
3636
5: iconst_3
3737
6: iadd
38-
7: putfield #2 // Field i:I
38+
7: putfield #2 // Field i:I
3939
10: return
4040
}
4141
*/

lowlevel/AtomicityTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
public class AtomicityTest implements Runnable {
99
private int i = 0;
1010
public int getValue() { return i; }
11-
private synchronized void evenIncrement() { i++; i++; }
11+
private synchronized void evenIncrement() {
12+
i++; i++;
13+
}
1214
@Override
1315
public void run() {
1416
while(true)
1517
evenIncrement();
1618
}
1719
public static void main(String[] args) {
1820
new TimedAbort(4);
19-
ExecutorService es = Executors.newCachedThreadPool();
21+
ExecutorService es =
22+
Executors.newCachedThreadPool();
2023
AtomicityTest at = new AtomicityTest();
2124
es.execute(at);
2225
while(true) {

lowlevel/CriticalSection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Synchronizing blocks instead of entire methods. Also
77
// demonstrates protection of a non-thread-safe class
88
// with a thread-safe one.
9-
// {java threads.CriticalSection}
10-
package threads;
9+
// {java lowlevel.CriticalSection}
10+
package lowlevel;
1111
import java.util.concurrent.*;
1212
import java.util.concurrent.atomic.*;
1313
import java.util.*;

lowlevel/ExplicitCriticalSection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Visit http://OnJava8.com for more book information.
55
// {ThrowsException} on a multiprocessor machine
66
// Using explicit Lock objects to create critical sections
7-
// {java threads.ExplicitCriticalSection}
8-
package threads;
7+
// {java lowlevel.ExplicitCriticalSection}
8+
package lowlevel;
99
import java.util.concurrent.locks.*;
1010

1111
// Synchronize the entire method:

lowlevel/QuittableTask.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

lowlevel/QuittingTasks.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)