Move code to core-java-modules/core-java-concurrency-advanced-3Add

Add missing 'Unit' in test name
This commit is contained in:
mthomas 2020-03-31 04:43:06 -05:00
parent 46b732527b
commit 6534bddb6c
2 changed files with 6 additions and 6 deletions

View File

@ -1,12 +1,12 @@
package com.baeldung.concurrent.atomic; package com.baeldung.atomicstampedreference;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicStampedReference; import java.util.concurrent.atomic.AtomicStampedReference;
public class SafeAccount { public class SafeAccount {
AtomicInteger stamp = new AtomicInteger(0); private AtomicInteger stamp = new AtomicInteger(0);
AtomicStampedReference<Integer> balance = new AtomicStampedReference<>(0, 0); private AtomicStampedReference<Integer> balance = new AtomicStampedReference<>(0, 0);
public int getBalance() { public int getBalance() {
return this.balance.get(new int[1]); return this.balance.get(new int[1]);

View File

@ -1,12 +1,12 @@
package com.baeldung.concurrent.atomic; package com.baeldung.atomicstampedreference;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class ThreadSafeAccountTest { public class ThreadSafeAccountUnitTest {
@Test @Test
public void givenMultiThread_whenSafeAccountSetBalance() throws InterruptedException { public void givenMultiThread_whenSafeAccount_thenSetBalance() throws InterruptedException {
SafeAccount account = new SafeAccount(); SafeAccount account = new SafeAccount();
Thread t = new Thread(() -> { Thread t = new Thread(() -> {
while (!account.withdrawal(100)) while (!account.withdrawal(100))