By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: Fray Detects Concurrency Issues in JVM Languages
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > News > Fray Detects Concurrency Issues in JVM Languages
News

Fray Detects Concurrency Issues in JVM Languages

News Room
Last updated: 2025/12/09 at 3:35 AM
News Room Published 9 December 2025
Share
Fray Detects Concurrency Issues in JVM Languages
SHARE

Carnegie Mellon University has introduced Fray, a concurrency testing tool for JVM programs to catch bugs and replay them. Written in Kotlin and based on this research paper, Fray can’t find all concurrency issues, but uses recent research to maximize the chances of detecting them. Fray uses shadow locking, a technique that incorporates extra locks to mediate access to shared resources in a specific order.

Fray supports Java versions including JDK 25 and has successfully discovered bugs in the JDK, Lucene, Kafka, Flink and Guava. The framework is capable of detecting multi-threading issues, but not bugs caused by concurrent memory writes.The following plugin and dependency configuration is required for Maven:


<plugin>
    <groupId>org.pastalab.fray.maven</groupId>
    <artifactId>fray-plugins-maven</artifactId>
    <version>0.6.9</version>
    <executions>
        <execution>
            <id>prepare-fray</id>
            <goals>
                <goal>prepare-fray</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<dependency>
    <groupId>org.pastalab.fray</groupId>
    <artifactId>fray-junit</artifactId>
    <version>0.6.9</version>
    <scope>test</scope>
</dependency>

Alternatively, the following plugin configuration can be used for Gradle:


plugins {
    id("org.pastalab.fray.gradle") version "0.6.9"
}

After configuring Gradle, the tests can be run with the following command:


./gradlew frayTest

Lastly, IntelliJ may be used to run Fray tests by following the IDE documentation on GitHub.

After configuring the build system, JUnit 5 can be used to run tests by annotating the class with @ExtendWith(FrayTestExtension.class) and annotating the tests with @ConcurrencyTest:


@ExtendWith(FrayTestExtension.class)
public class MyFirstTest {
    @ConcurrencyTest
    public void myTest() {
        …
    }
}

The following BankAccount class is a simplified example that might result in a deadlock when multiple threads access the synchronized code:


public class BankAccount {
    public BankAccount(double balance) {
        this.balance = balance;
    }

    private double balance;

    public void transfer(double amount, BankAccount toAccount) {
        synchronized (this) {
            synchronized (toAccount) {
                this.balance -= amount;
                toAccount.balance += amount;
            }
        }
    }
}

To detect the deadlock, a Fray test is created, which explicitly sets the number of iterations to ten. The complete set of parameters can be found in the ConcurrencyTest.kt on GitHub.


@ExtendWith(FrayTestExtension.class)
public class BankAccountTest {
    public void myBankAccountTest() throws InterruptedException {
        BankAccount bankAccount1 = new BankAccount(5000);
        BankAccount bankAccount2 = new BankAccount(6000);

        Thread thread1 = new Thread(() -> {
            bankAccount1.transfer(100, bankAccount2);
        });

        Thread thread2 = new Thread(() -> {
            bankAccount2.transfer(50, bankAccount1);
        });

        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
    }

    @ConcurrencyTest(
            iterations = 10,
            )
    public void runMyBankAccountTestUsingFray() throws InterruptedException {
        myBankAccountTest();
    }
}

Running the above test results in the following error after the first four (out of ten) iterations:


[ERROR] Errors: 
[ERROR] org.example.BankAccountTest.runMyBankAccountTestUsingFray
[INFO]   Run 1: PASS
[INFO]   Run 2: PASS
[INFO]   Run 3: PASS
[ERROR]   Run 4: BankAccountTest.runMyBankAccountTestUsingFray:33->myBankAccountTest:25->Object.wait:-1 » Deadlock
[INFO]   Run 5: PASS
[INFO]   Run 6: PASS
[INFO]   Run 7: PASS
[INFO]   Run 8: PASS
[INFO]   Run 9: PASS
[INFO]   Run 10: PASS

Alternatively, for other testing frameworks apart from JUnit, the FrayInTestLauncher class may be used:


public void myTest() {
    FrayInTestLauncher.INSTANCE.launchFrayTest(() -> {
        …
    });
}

Fray will automatically generate a test case when a test fails, to reproduce the failure. Detailed information is logged in the report folder. When using Maven, the report folder is located inside target/fray/fray-report. This folder may be used to reproduce the failure in two different ways.

The first option is to rerun the test with the same scheduler and recorded random choices as described in the Feedback-guided Adaptive Testing of Distributed Systems Designs paper. Therefore, the path to the replay file should be set in the ConcurrencyTest annotation:


@ConcurrencyTest(
        replay = "[path to report]/recording"
)

Running the test again immediately results in the following error:


Error: org.pastalab.fray.runtime.DeadlockException

The test passes after resolving the deadlock inside the example application.

Alternatively, the test can be executed again with the exact thread schedule observed in the original execution. Therefore, the schedule needs to be recorded with the following Java option: -Dfray.recordSchedule=true. After recording the schedule, the ReplayScheduler class should be used in the ConcurrencyTest annotation:


@ConcurrencyTest(
    scheduler = ReplayScheduler.class,
    replay = "[path to report]/recording"
)

Alternative frameworks to detect concurrency issues in Java code include VMLens, Java Concurrency Stress (jcstress), and Lincheck from IntelliJ IDEA. More information on Fray can be found in the usage guide or in the technical report.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Using Ringless Voicemail to Support Social Media Campaigns | Using Ringless Voicemail to Support Social Media Campaigns |
Next Article Xunlei acquires male-focused sports community Hupu for RMB 500 million · TechNode Xunlei acquires male-focused sports community Hupu for RMB 500 million · TechNode
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

Virgin Atlantic wants you to use ChatGPT to book your next holiday. Yes, really
Virgin Atlantic wants you to use ChatGPT to book your next holiday. Yes, really
Gadget
Department of Commerce approves Nvidia H200 chip exports to China |  News
Department of Commerce approves Nvidia H200 chip exports to China | News
News
10 Pinterest SEO Hacks to Skyrocket Your Blog Traffic
10 Pinterest SEO Hacks to Skyrocket Your Blog Traffic
Computing
Will Smith And Charlton Heston Starred In Two Different Adaptations Of The Same Post-Apocalyptic Novel – BGR
Will Smith And Charlton Heston Starred In Two Different Adaptations Of The Same Post-Apocalyptic Novel – BGR
News

You Might also Like

Department of Commerce approves Nvidia H200 chip exports to China |  News
News

Department of Commerce approves Nvidia H200 chip exports to China | News

4 Min Read
Will Smith And Charlton Heston Starred In Two Different Adaptations Of The Same Post-Apocalyptic Novel – BGR
News

Will Smith And Charlton Heston Starred In Two Different Adaptations Of The Same Post-Apocalyptic Novel – BGR

6 Min Read

Australia’s social media ban leaves a 15-year-old worried about losing touch with friends

8 Min Read

Google facing a new antitrust probe in Europe over content it uses for AI

3 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?