Book Image

OpenJDK Cookbook

Book Image

OpenJDK Cookbook

Overview of this book

Table of Contents (20 chapters)
OpenJDK Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Writing tests for jcstress


The Java Concurrency Stress test is a wonderful tool that is used by JDK authors to ensure that their concurrent code works correctly with regards to concurrency. Concurrent code is hard to write and even harder to test. Most of their tests are probabilistic, require a lot of skill to write, and might take many days running time and the appropriate hardware to exhibit the fail behavior. Considering all this complexity, having a framework that can help with correct test execution is a big advantage. This recipe will go through the steps that are required to write your own tests for jcstress.

Getting ready

To follow this recipe, the only requirement is to have an environment that is capable of compiling and running jcstress (see the Building and running jcstress recipe).

How to do it…

The following steps will lead you through the process of creating a test and running it using jcstress:

  1. To start, we will need a code to test. Let's pick the problem which, arguably, is...