Testing concurrency code with MultithreadedTC
MultithreadedTC
is a Java library for testing concurrent applications. Its main objective is to solve the problem of concurrent applications being non-deterministic. You can't control the order of execution of the different threads that form the application. For this purpose, it includes an internal metronome. These testing threads are implemented as methods of a class.
In this recipe, you will learn how to use the MultithreadedTC
library to implement a test for LinkedTransferQueue
.
Getting ready
Download the MultithreadedTC library from https://code.google.com/archive/p/multithreadedtc/ and the JUnit library, version 4.10, from http://junit.org/junit4/. Add the junit-4.10.jar
and MultithreadedTC-1.01.jar
files to the libraries of the project.
How to do it...
Follow these steps to implement the example:
- Create a class named
ProducerConsumerTest
that extends theMultithreadedTestCase
class:
public class ProducerConsumerTest extends MultithreadedTestCase...