Skip to content

Commit 85ff834

Browse files
author
Bruce Eckel
committed
Removed {TimeOutDuringTesting}
1 parent 2478dc1 commit 85ff834

File tree

10 files changed

+19
-9
lines changed

10 files changed

+19
-9
lines changed

polymorphism/Frog.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Cleanup and inheritance
6+
// {main: polymorphism.Frog}
67
package polymorphism;
78

89
class Characteristic {

standardio/Echo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// How to read from standard input
6-
// {TimeOutDuringTesting}
76
import java.io.*;
7+
import onjava.TimedAbort;
88

99
public class Echo {
1010
public static void
1111
main(String[] args) throws IOException {
12+
new TimedAbort(4);
1213
BufferedReader stdin = new BufferedReader(
1314
new InputStreamReader(System.in));
1415
String s;

threads/AtomicEvenSupplier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Atomic classes are occasionally useful in regular code
6-
// {TimeOutDuringTesting}
76
// {IgnoreOutput} // No output validation
87
import java.util.concurrent.atomic.*;
8+
import onjava.TimedAbort;
99

1010
public class AtomicEvenSupplier extends IntSupplier {
1111
private AtomicInteger currentEvenValue =
@@ -15,6 +15,7 @@ public int next() {
1515
return currentEvenValue.addAndGet(2);
1616
}
1717
public static void main(String[] args) {
18+
new TimedAbort(4);
1819
EvenChecker.test(new AtomicEvenSupplier());
1920
}
2021
}

threads/AtomicityTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5-
// {TimeOutDuringTesting}
65
import java.util.concurrent.*;
6+
import onjava.TimedAbort;
77

88
public class AtomicityTest implements Runnable {
99
private int i = 0;
@@ -15,6 +15,7 @@ public void run() {
1515
evenIncrement();
1616
}
1717
public static void main(String[] args) {
18+
new TimedAbort(4);
1819
ExecutorService es = Executors.newCachedThreadPool();
1920
AtomicityTest at = new AtomicityTest();
2021
es.execute(at);

threads/CaptureUncaughtException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5-
// {TimeOutDuringTesting}
65
import java.util.concurrent.*;
6+
import onjava.TimedAbort;
77

88
class ExceptionThread2 implements Runnable {
99
@Override
@@ -40,6 +40,7 @@ public Thread newThread(Runnable r) {
4040

4141
public class CaptureUncaughtException {
4242
public static void main(String[] args) {
43+
new TimedAbort(4);
4344
ExecutorService exec = Executors.newCachedThreadPool(
4445
new HandlerThreadFactory());
4546
exec.execute(new ExceptionThread2());

threads/CriticalSection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5-
// {TimeOutDuringTesting}
65
// (Behavior may have changed in Java 8)
76
// Synchronizing blocks instead of entire methods. Also
87
// demonstrates protection of a non-thread-safe class
@@ -11,6 +10,7 @@
1110
import java.util.concurrent.*;
1211
import java.util.concurrent.atomic.*;
1312
import java.util.*;
13+
import onjava.TimedAbort;
1414

1515
class Pair { // Not thread-safe
1616
private int x, y;
@@ -139,6 +139,7 @@ public class CriticalSection {
139139
System.exit(0);
140140
}
141141
public static void main(String[] args) {
142+
new TimedAbort(4);
142143
PairManager
143144
pman1 = new PairManager1(),
144145
pman2 = new PairManager2();

threads/EvenSupplier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// When threads collide
6-
// {TimeOutDuringTesting}
6+
import onjava.TimedAbort;
77

88
public class EvenSupplier extends IntSupplier {
99
private int currentEvenValue = 0;
@@ -14,6 +14,7 @@ public int next() {
1414
return currentEvenValue;
1515
}
1616
public static void main(String[] args) {
17+
new TimedAbort(4);
1718
EvenChecker.test(new EvenSupplier());
1819
}
1920
}

threads/MutexEvenSupplier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Preventing thread collisions with mutexes
6-
// {TimeOutDuringTesting}
76
// {IgnoreOutput} // No output validation
87
import java.util.concurrent.locks.*;
8+
import onjava.TimedAbort;
99

1010
public class MutexEvenSupplier extends IntSupplier {
1111
private int currentEvenValue = 0;
@@ -23,6 +23,7 @@ public int next() {
2323
}
2424
}
2525
public static void main(String[] args) {
26+
new TimedAbort(4);
2627
EvenChecker.test(new MutexEvenSupplier());
2728
}
2829
}

threads/SettingDefaultHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5-
// {TimeOutDuringTesting}
65
import java.util.concurrent.*;
6+
import onjava.TimedAbort;
77

88
public class SettingDefaultHandler {
99
public static void main(String[] args) {
10+
new TimedAbort(4);
1011
Thread.setDefaultUncaughtExceptionHandler(
1112
new MyUncaughtExceptionHandler());
1213
ExecutorService es = Executors.newCachedThreadPool();

threads/SynchronizedEvenSupplier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Simplifying mutexes with the synchronized keyword
6-
// {TimeOutDuringTesting}
76
// {IgnoreOutput} // No output validation
7+
import onjava.TimedAbort;
88

99
public class
1010
SynchronizedEvenSupplier extends IntSupplier {
@@ -17,6 +17,7 @@ public synchronized int next() {
1717
return currentEvenValue;
1818
}
1919
public static void main(String[] args) {
20+
new TimedAbort(4);
2021
EvenChecker.test(new SynchronizedEvenSupplier());
2122
}
2223
}

0 commit comments

Comments
 (0)