...
Code Block | ||
---|---|---|
| ||
public final class Foo implements Runnable { public void run() { // ... } public static void main(String[] args) { Foo ffoo = new fooFoo(); new Thread(ffoo).run(); } } |
The start()
method is not invoked on the new thread because of the incorrect assumption that run()
starts the new thread. Consequently, the statements in the run()
method execute in the same thread instead of the new one.
...
Code Block | ||
---|---|---|
| ||
public final class Foo implements Runnable { public void run() { // ... } public static void main(String[] args) { Foo ffoo = new fooFoo(); new Thread(ffoo).start(); } } |
Exceptions
EX1: The run()
method may be invoked when unit testing its functionality. Note that a class cannot be tested for multithreaded use by invoking run()
directly.
...