...
Code Block | ||
---|---|---|
| ||
public final class Foo implements Runnable { @Override public void run() { // ... } public static void main(String[] args) { Foo foo = new Foo(); new Thread(foo).start(); } } |
Exceptions
THI00-J-EX0: The run()
method may be directly invoked during unit testing. Note that this method cannot be used to test a class for multithreaded use.
...
Casting a thread to Runnable
before calling the run()
method documents that the explicit call to Thread.run()
is intentional. Adding an explanatory comment alongside the invocation is highly recommended.
THI00-J-EX1: Runtime system code involved in starting new threads is permitted to invoke a Thread
object's run()
method directly; this is an obvious necessity for a working Java runtime system. Note that the likelihood that this exception applies to user-written code is vanishingly small.
...