Test the Thread Task Directly

Object-oriented threading libraries generally separate the modeling of a thread from the modeling of the task that the thread runs. Usually, there are also convenience facilities to just use the thread model directly rather than explicitly creating separate instances for each. From its inception, Java has had a Thread class and has represented the task with the Runnable interface. A Thread is a Runnable, and its default implementation runs itself as its task.

Shortcomings in this design3 motivated the addition of the java.util.concurrent packages to Java 5. In addition to a broad range of new synchronization facilities, it added Executor as the model of execution and Callable as the model for the task. The new packages ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.