Perform the following steps to implement the example:
- First, implement your own worker thread class. Create a class named AlwaysThrowsExceptionWorkerThread that extends the ForkJoinWorkerThread class:
public class AlwaysThrowsExceptionWorkerThread extends ForkJoinWorkerThread {
- Implement the constructor of the class. It receives a ForkJoinPool class as a parameter and calls the constructor of its parent class:
protected AlwaysThrowsExceptionWorkerThread(ForkJoinPool pool) { super(pool); }
- Implement the onStart() method. This is a method of the ForkJoinWorkerThread class and is executed when the worker thread begins its execution. The implementation will throw a RuntimeException exception upon being called:
protected ...