THE Java™ Programming Language, Fourth Edition
Exactly when preemption can occur depends on the virtual machine you have. There are no guarantees, only a general expectation t ...
up in exactly the specified time. Other thread scheduling can interfere, as can the granularity and accuracy of the system clock ...
The output may well look like this: Did Did DidNot DidNot If each thread yields after each println, other printing threads will ...
class Friendly { private Friendly partner; private String name; public Friendly(String name) { this.name = name; } public synchr ...
And when you run the program, you might get the following output before the program "hangs": Thread1 in jareth.hug() trying to i ...
make a thread cancellable takes a bit of work on the programmer's part, but it is a clean and safe mechanism for getting a threa ...
The tick method prints a dot every pauseTime milliseconds up to a maximum of count timessee "Timer and TimerTask" on page 653 fo ...
System.out.println("result is " calc.getResult()); } catch (InterruptedException e) { System.out.println("No answer: interrupte ...
no chance for any cleanupso daemon threads are limited in what they can do. You use the method setDaemon(true) to mark a thread ...
perspective this set of values should only consist of a single value: that value most recently written by some thread. However, ...
used for simple flags to indicate something has occurred, or for writing lock-free algorithms that incorporate use of the atomic ...
reference was written. For example, this means that if one thread constructs an object and uses methods on that object to set it ...
strategy using the tools in this book, the subtleties of the memory model will work for you and your code will be fine. 14.11. T ...
A thread group can be a daemon groupwhich is totally unrelated to the concept of daemon threads. A daemon THReadGroup is automat ...
public final booleanisDaemon() Returns the daemon status of this thread group. public final voidsetMaxPriority(int maxPri) Sets ...
Equivalent to enumerate(threadsInGroup,true). public intactiveGroupCount() Like activeCount, but counts groups, instead of threa ...
remain within the thread. If a "parent" thread wants to know why a "child" terminated, the child will have to store that informa ...
14.12.1. Don't stop We mentioned in Chapter 12 that two forms of asynchronous exceptions are definedinternal errors in the Java ...
may well never need, but if you do need it THReadLocal may simplify your work. For example, you might want to have a user object ...
someone uses your class in a thread pool, the behavior might be dangerously wrong. For example, the users variable in the Operat ...
«
11
12
13
14
15
16
17
18
19
20
»
Free download pdf