Java 8 AtomicBoolean - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AtomicBoolean class.

This code example shows how to use the following methods:sleep, get
            stateSequencer.advance("t1:s1", 10, SECONDS); 
            return null; 
         } 
      }); 
 
      final AtomicBoolean t2s2Entered = new AtomicBoolean(false);
      Future<Object> future2 = fork(new Callable<Object>() {
         @Override 
         public Object call() throws Exception { 
            stateSequencer.enter("t2:s2", 10, SECONDS); 
            t2s2Entered.set(true); 
            stateSequencer.exit("t2:s2"); 
            return null; 
         } 
      }); 
 
      stateSequencer.enter("start", 0, SECONDS);
      Thread.sleep(500);
      assertFalse(future1.isDone()); 
      assertFalse(future2.isDone()); 

9
CodeRank
This code example shows how to use the following methods:
 * to reset the global / suite level cluster if a test fails but don't wanna reset it 
 * for every subsequent test. 
 */ 
public class CurrentTestFailedMarker extends RunListener { 
 
    private static final AtomicBoolean failed = new AtomicBoolean(false);
 
    @Override 
    public void testFailure(Failure failure) throws Exception {
        failed.set(true);
    } 
 
    @Override 
    public void testStarted(Description description) throws Exception {
        failed.set(false);
    } 
 
    /** 
     * Returns <code>true</code> iff the previously executed test failed. Otherwise <code>false</code> 
     */ 
8
CodeRank
This code example shows how to use the following methods:
 * @see org.elasticsearch.env.NodeEnvironment 
 */ 
public abstract class ShardLock implements Closeable {
 
    private final ShardId shardId;
    private final AtomicBoolean closed = new AtomicBoolean(false);
 
    public ShardLock(ShardId id) {
        this.shardId = id;
    } 
 
    /** 
     * Returns the locks shards Id. 
     */ 
    public final ShardId getShardId() { 
        return shardId;
    } 
 
    @Override 
    public final void close() throws IOException {
8
CodeRank
This code example shows how to use the following methods:
 
    public static final ServiceName DEFAULT_SERVICE_NAME = ServiceName.JBOSS.append("test", "myservice", "default");
    public static final ServiceName QUORUM_SERVICE_NAME = ServiceName.JBOSS.append("test", "myservice", "quorum");
 
    private final Value<ServerEnvironment> env;
    private final AtomicBoolean started = new AtomicBoolean(false);
 
    public MyService(Value<ServerEnvironment> env) {
        this.env = env;
    } 
 
    @Override 
    public Environment getValue() {
        if (!this.started.get()) {
            throw new IllegalStateException();
        } 
        return new Environment(this.env.getValue().getNodeName());
    } 
 
    @Override 
8
CodeRank
This code example shows how to use the following methods:compareAndSet, get
        return (lastAccessedTime != null) && (timeout > 0) ? ((System.currentTimeMillis() - lastAccessedTime.getTime()) > timeout) : false;
    } 
 
    @Override 
    public void remove(RemoveListener<T> listener) {
        if (this.valid.compareAndSet(true, false)) {
            InfinispanEjbLogger.ROOT_LOGGER.tracef("Removing bean %s", this.id);
            this.remover.remove(this.id, listener);
            this.close();
        } 
    } 
 
    @Override 
    public T acquire() { 
        InfinispanEjbLogger.ROOT_LOGGER.tracef("Acquiring reference to bean %s", this.id);
        return this.group.getBean(this.id, this.listener);
    } 
 
    @Override 
    public boolean release() { 

7
CodeRank
This code example shows how to use the following methods:get, set
        return this;
    } 
 
    @Override 
    public void invalidate() { 
        if (!valid.get()) throw new IllegalStateException();
        valid.set(false);
    } 
 
    @Override 
    public boolean isNew() { 
        if (!valid.get()) throw new IllegalStateException();
        return false; 
    } 
 
 
} 
7
CodeRank
This code example shows how to use the following methods:get
     * Start indexing 
     * 
     * @param numOfDocs number of document to index before pausing. Set to -1 to have no limit. 
     */ 
    public void start(int numOfDocs) {
        assert !stop.get() : "background indexer can not be started after it has stopped";
        setBudget(numOfDocs);
        startLatch.countDown();
    } 
 
    /** Pausing indexing by setting current document limit to 0 */ 
    public void pauseIndexing() { 
        availableBudget.drainPermits();
        setBudget(0); 
    } 
 
    /** Continue indexing after it has paused. No new document limit will be set */ 
    public void continueIndexing() { 
        continueIndexing(-1); 
    } 
8
CodeRank
This code example shows how to use the following methods:
	public PullToRefreshWebView2(Context context, Mode mode) {
		super(context, mode);
	} 
 
	private JsValueCallback mJsCallback;
	private final AtomicBoolean mIsReadyForPullDown = new AtomicBoolean(false);
	private final AtomicBoolean mIsReadyForPullUp = new AtomicBoolean(false);
 
	@Override 
	protected WebView createRefreshableView(Context context, AttributeSet attrs) {
		WebView webView = super.createRefreshableView(context, attrs);
 
		// Need to add JS Interface so we can get the response back 
		mJsCallback = new JsValueCallback();
		webView.addJavascriptInterface(mJsCallback, JS_INTERFACE_PKG);
 
		return webView;
	} 
 
	@Override 
8
CodeRank
This code example shows how to use the following methods:
 * 
 * @author Scott Marlow 
 */ 
public class TestEntityManager implements InvocationHandler {
 
    private static AtomicBoolean closedByReaperThread = new AtomicBoolean(false);
    private static final List<String> invocations = Collections.synchronizedList(new ArrayList<String>());
 
    @Override 
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 
        invocations.add(method.getName());
        System.out.println("TestEntityManager method=" + method.getName());
 
        if(method.getName().equals("persist")) {
            return persist(); 
        } 
 
        if(method.getName().equals("close")) {
            return close(); 
7
CodeRank
This code example shows how to use the following methods:get
        } 
    } 
 
    @Override 
    public PersistenceResource store(final ModelNode model, Set<PathAddress> affectedAddresses) throws ConfigurationPersistenceException {
        if(!successfulBoot.get()) {
            return new PersistenceResource() { 
                public void commit() { 
                } 
 
                public void rollback() { 
                } 
            }; 
        } 
        return new ConfigurationFilePersistenceResource(model, configurationFile, this);
    } 
 
    @Override 
    public String snapshot() throws ConfigurationPersistenceException {
        return configurationFile.snapshot();
7
CodeRank

Related Java 8 AtomicBoolean Questions & Answers:

See Code Examples for Java 8 AtomicBoolean Methods: