Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.mapdb;/*
  * Written by Doug Lea with assistance from members of JCP JSR-166
  * Expert Group and released to the public domain, as explained at
  * Other contributors include Andrew Wright, Jeffrey Hayes, 
  * Pat Fisher, Mike Judd. 
public class AtomicBooleanTest extends TestCase{
    DB db = DBMaker.newMemoryDB().transactionDisable().make();
    Atomic.Boolean ai = .createAtomicBoolean("test"true);

constructor initializes to given value
    public void testConstructor() {

default constructed initializes to false
    public void testConstructor2() {
        Atomic.Boolean ai = .getAtomicBoolean("test2");

get returns the last value set
    public void testGetSet() {

compareAndSet succeeds in changing value if equal to expected else fails
    public void testCompareAndSet() {

compareAndSet in one thread enables another waiting for value to succeed
        Thread t = new Thread(new Runnable() {
            public void run() {
                while(!.compareAndSet(falsetrue)) Thread.yield();

getAndSet returns previous value and sets to given value
    public void testGetAndSet() {
toString returns current value.
    public void testToString() {
        Atomic.Boolean ai = .getAtomicBoolean"test2");
        assertEquals(ai.toString(), Boolean.toString(false));
        assertEquals(ai.toString(), Boolean.toString(true));
New to GrepCode? Check out our FAQ X