Skip to content

Commit

Permalink
Update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
aoli-al committed Aug 8, 2024
1 parent 600e763 commit 12deb63
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
# Fray: General-Purpose Concurrency Testing

Fray is a general-purpose concurrency testing tool that can be used to test Java applications. Fray is built on top of the Java Virtual Machine (JVM) and uses a combination of static and dynamic analysis to test concurrent programs.
Fray is designed to be easy to use and can be integrated into existing testing frameworks.

## Getting Started

Consider you have a Java application that has a currency component (e.g., an asynchronous worker).

```java
public class TestExample extends Thread {
static AtomicInteger a = new AtomicInteger();
public void run() {
int x = a.getAndIncrement();
synchronized (o) {
if (x % 2 == 0) {
try {
o.wait();
} catch (InterruptedException ignore) {
}
} else {
o.notify();
}
}
}
}
```

In order to find bugs in the application, developers usually implement *hammer* tests, which run the application with a large number of threads and hope to find bugs.

```java
@Test
public void MyHammerTest() {
for (int i = 0; i < 1000; i++) {
new TestExample().start();
}
}
```

However, this approach is not effective because it is hard to reproduce the bug and the test is non-deterministic. Fray
is designed to solve this problem. Simply replace `@Test` with `@ConcurrencyTest`, and Fray will automatically test
the application with different interleavings **deterministically**, and you don't need to launch the test with a large number of threads.

```java
@ConcurrencyTest
public void MyHammerTest() {
for (int i = 0; i < 2; i++) {
new TestExample().start();
}
}
```


## Requirements

Please make sure you have Java 21 installed. To build the native plugin, you also need to have `g++` and `cmake` installed.
Expand Down

0 comments on commit 12deb63

Please sign in to comment.