This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example.example6DataRace.anotherexample; | |
import org.example.bankaccount.BankAccount; | |
import org.example.bankaccount.BankAccountWithStampedLock; | |
import org.junit.jupiter.api.DisplayName; | |
import org.junit.jupiter.api.RepeatedTest; | |
import java.util.concurrent.Executors; | |
import static org.junit.jupiter.api.Assertions.assertEquals; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example.bankaccount; | |
import java.util.concurrent.locks.StampedLock; | |
import java.util.function.Supplier; | |
public class BankAccountWithStampedLock { | |
private final StampedLock stampedLock = new StampedLock(); | |
private BankAccount bankAccount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example.bankaccount; | |
import java.util.concurrent.atomic.AtomicReference; | |
public class BankAccountWithAtomicReference { | |
private AtomicReference<BankAccount> atomicBalance = new AtomicReference<>(new BankAccount()); | |
public void deposit(double amount) { | |
BankAccount oldBalance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example.bankaccount; | |
/** | |
* Bank Account | |
*/ | |
public class BankAccount { | |
private double balance; | |
public void deposit(double amount) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.watcher.watcherdir; | |
import java.io.IOException; | |
import java.nio.file.FileSystems; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.WatchEvent; | |
import java.nio.file.WatchKey; | |
import java.nio.file.WatchService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//DEPS io.projectreactor:reactor-core:3.6.0 | |
import reactor.core.publisher.Mono; | |
import reactor.core.scheduler.Schedulers; | |
import java.io.IOException; | |
import java.net.URI; | |
import java.net.http.HttpClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.*; | |
import java.util.Objects; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ScheduledExecutorService; | |
import java.util.concurrent.ScheduledFuture; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.AtomicReference; |