当前位置: 首页>>代码示例>>Java>>正文


Java AtomicBoolean.get方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.AtomicBoolean.get方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicBoolean.get方法的具体用法?Java AtomicBoolean.get怎么用?Java AtomicBoolean.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.AtomicBoolean的用法示例。


在下文中一共展示了AtomicBoolean.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRemoveLibraries

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
private boolean addRemoveLibraries(final Library[] libraries, SourceGroup grp, String type, final boolean add) throws IOException {
        final AtomicBoolean modified = new AtomicBoolean();
        final String scope = findScope(grp, type);
        ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
            public @Override void performOperation(POMModel model) {
                for (Library library : libraries) {
                    try {
                        modified.compareAndSet(false, addRemoveLibrary(library, model, scope, add));
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            }
        };
        FileObject pom = project.getProjectDirectory().getFileObject(POM_XML);//NOI18N
        org.netbeans.modules.maven.model.Utilities.performPOMModelOperations(pom, Collections.singletonList(operation));
        //TODO is the manual reload necessary if pom.xml file is being saved?
//                NbMavenProject.fireMavenProjectReload(project);
        if (modified.get()) {
            project.getLookup().lookup(NbMavenProject.class).triggerDependencyDownload();
        }
        return modified.get();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:CPExtender.java

示例2: putIfAbsent

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
/**
 * If {@code key} is not already associated with a value or if {@code key} is associated with
 * zero, associate it with {@code newValue}. Returns the previous value associated with
 * {@code key}, or zero if there was no mapping for {@code key}.
 */
long putIfAbsent(K key, long newValue) {
  AtomicBoolean noValue = new AtomicBoolean(false);
  Long result =
      map.compute(
          key,
          (k, oldValue) -> {
            if (oldValue == null || oldValue == 0) {
              noValue.set(true);
              return newValue;
            } else {
              return oldValue;
            }
          });
  return noValue.get() ? 0L : result.longValue();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:AtomicLongMap.java

示例3: call

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
public void call(Subscriber<? super T> subscriber) {
    this.lock.lock();
    if (this.subscriptionCount.incrementAndGet() == 1) {
        AtomicBoolean writeLocked = new AtomicBoolean(true);
        try {
            this.source.connect(onSubscribe(subscriber, writeLocked));
        } finally {
            if (writeLocked.get()) {
                this.lock.unlock();
            }
        }
    } else {
        try {
            doSubscribe(subscriber, this.baseSubscription);
        } finally {
            this.lock.unlock();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:OnSubscribeRefCount.java

示例4: deleteRealm

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
/**
 * Deletes the Realm file defined by the given configuration.
 */
static boolean deleteRealm(final RealmConfiguration configuration) {
    final AtomicBoolean realmDeleted = new AtomicBoolean(true);
    boolean callbackExecuted = OsObjectStore.callWithLock(configuration, new Runnable() {
        @Override
        public void run() {
            String canonicalPath = configuration.getPath();
            File realmFolder = configuration.getRealmDirectory();
            String realmFileName = configuration.getRealmFileName();
            realmDeleted.set(Util.deleteRealm(canonicalPath, realmFolder, realmFileName));
        }
    });
    if (!callbackExecuted) {
        throw new IllegalStateException("It's not allowed to delete the file associated with an open Realm. " +
                "Remember to close() all the instances of the Realm before deleting its file: "
                + configuration.getPath());
    }
    return realmDeleted.get();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:BaseRealm.java

示例5: when_minimalParameters

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
@Test
public void when_minimalParameters()
  throws Throwable
{
  final Observable observable = Arez.context().createObservable();

  final AtomicBoolean result = new AtomicBoolean();

  final AtomicInteger conditionRun = new AtomicInteger();
  final AtomicInteger effectRun = new AtomicInteger();

  final SafeFunction<Boolean> condition = () -> {
    conditionRun.incrementAndGet();
    observable.reportObserved();
    return result.get();
  };
  final SafeProcedure procedure = effectRun::incrementAndGet;

  final Disposable node = ArezExtras.when( condition, procedure );

  assertTrue( node instanceof Watcher );
  final Watcher watcher = (Watcher) node;
  assertEquals( watcher.getName(), "[email protected]", "The name has @2 as one other Arez entity created (Observable)" );
  assertEquals( conditionRun.get(), 1 );
  assertEquals( effectRun.get(), 0 );
}
 
开发者ID:arez,项目名称:arez,代码行数:27,代码来源:ArezExtrasTest.java

示例6: waitIfPaused

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
/** @return true - if task should be interrupted; false - otherwise */
private boolean waitIfPaused() {
	AtomicBoolean pause = engine.getPause();
	synchronized (pause) {
		if (pause.get()) {
			log(LOG_WAITING_FOR_RESUME);
			try {
				pause.wait();
			} catch (InterruptedException e) {
				L.e(LOG_TASK_INTERRUPTED, memoryCacheKey);
				return true;
			}
			log(LOG_RESUME_AFTER_PAUSE);
		}
	}
	return checkTaskIsNotActual();
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:18,代码来源:LoadAndDisplayImageTask.java

示例7: waitForConditionEx

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
public static void waitForConditionEx(final AtomicBoolean condition)
throws InterruptedException
  {
      synchronized (condition) {
          while (!condition.get()) {
              condition.wait();
          }
      }
  }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:Util.java

示例8: any

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
public static <ResultType> Promise<ResultType> any(final Collection<Promise<ResultType>> promises) {
    final Promisor<ResultType> promisor = Promisor.create();
    final AtomicInteger failedCount = new AtomicInteger();
    final Lock lock = new ReentrantLock();
    final AtomicBoolean fullfilled = new AtomicBoolean();
    ChainCallback<ResultType> chainCallback = new ChainCallback<ResultType>() {
        @Override
        public void onSuccess(ResultType result) {
            lock.lock();
            if (!fullfilled.get()) {
                fullfilled.set(true);
                lock.unlock();
                promisor.fulfillPromise(result);
                return;
            }
            lock.unlock();
        }

        @Override
        public void onFail(Exception exception) {
            lock.lock();
            if (failedCount.incrementAndGet() == promises.size()) {
                lock.unlock();
                promisor.failPromise(new Exception("All promises have been failed."));
                return;
            }
            lock.unlock();
        }
    };
    for (Promise<ResultType> promise : promises) {
        promise.finishChain(chainCallback);
    }
    return promisor.promise();
}
 
开发者ID:BohdanHolyshevskyi,项目名称:little-promise,代码行数:35,代码来源:Promises.java

示例9: hasNext

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
@Override
public boolean hasNext() {
    final AtomicBoolean result = new AtomicBoolean(false);
    if (this.json() != null
        && (
        (this.current.get() < this.limit
            && this.supply(this.current.get()) != null)
            || this.navigationNext())) {
        result.set(true);
    }
    return result.get();
}
 
开发者ID:smallcreep,项目名称:cedato-api-client,代码行数:13,代码来源:SupIterator.java

示例10: getResult

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
public @Override synchronized Result getResult() {
    if (result == null && !building) {
        AtomicBoolean _building = new AtomicBoolean();
        AtomicReference<Result> _result = new AtomicReference<Result>(Result.NOT_BUILT);
        connector.getJobBuildResult(this, _building, _result);
        building = _building.get();
        result = _result.get();
    }
    return result != null ? result : Result.NOT_BUILT;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:HudsonJobBuildImpl.java

示例11: testImpl

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
@Override
public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item)
{
	final AtomicBoolean canSweep = new AtomicBoolean(false);
	if (effector.getActingPlayer() != null)
	{
		final L2PcInstance sweeper = effector.getActingPlayer();
		if (skill != null)
		{
			skill.forEachTargetAffected(sweeper, effected, o ->
			{
				if (o instanceof L2Attackable)
				{
					final L2Attackable target = (L2Attackable) o;
					if (target.isDead())
					{
						if (target.isSpoiled())
						{
							canSweep.set(target.checkSpoilOwner(sweeper, true));
							if (canSweep.get())
							{
								canSweep.set(!target.isOldCorpse(sweeper, Config.CORPSE_CONSUME_SKILL_ALLOWED_TIME_BEFORE_DECAY, true));
							}
							if (canSweep.get())
							{
								canSweep.set(sweeper.getInventory().checkInventorySlotsAndWeight(target.getSpoilLootItems(), true, true));
							}
						}
						else
						{
							sweeper.sendPacket(SystemMessageId.SWEEPER_FAILED_TARGET_NOT_SPOILED);
						}
					}
				}
			});
		}
	}
	return (_val == canSweep.get());
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:40,代码来源:ConditionPlayerCanSweep.java

示例12: performAction

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
@Override
@NbBundle.Messages({
    "MSG_GitAction.actionDisabled=Action cannot be executed,\nit is disabled in the current context.",
    "MSG_GitAction.savingFiles.progress=Preparing Git action"
})
protected final void performAction(final Node[] nodes) {
    final AtomicBoolean canceled = new AtomicBoolean(false);
    Runnable run = new Runnable() {

        @Override
        public void run () {
            if (!enableFull(nodes)) {
                Logger.getLogger(GitAction.class.getName()).log(Level.INFO, "Action got disabled, execution stopped");
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.MSG_GitAction_actionDisabled()));
                return;
            }
            LifecycleManager.getDefault().saveAll();
            Utils.logVCSActionEvent("Git"); //NOI18N
            if (!canceled.get()) {
                EventQueue.invokeLater(new Runnable() {

                    @Override
                    public void run () {
                        performContextAction(nodes);
                    }
                });
            }
        }
    };
    ProgressUtils.runOffEventDispatchThread(run, Bundle.MSG_GitAction_savingFiles_progress(), canceled, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:GitAction.java

示例13: timeout

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
public boolean timeout() {
    AtomicBoolean result = new AtomicBoolean();
    request.getCoyoteRequest().action(ActionCode.ASYNC_TIMEOUT, result);

    if (result.get()) {

        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
        ClassLoader newCL = request.getContext().getLoader().getClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(newCL);
            List<AsyncListenerWrapper> listenersCopy =
                new ArrayList<AsyncListenerWrapper>();
            listenersCopy.addAll(listeners);
            for (AsyncListenerWrapper listener : listenersCopy) {
                try {
                    listener.fireOnTimeout(event);
                } catch (Throwable t) {
                    ExceptionUtils.handleThrowable(t);
                    log.warn("onTimeout() failed for listener of type [" +
                            listener.getClass().getName() + "]", t);
                }
            }
            request.getCoyoteRequest().action(
                    ActionCode.ASYNC_IS_TIMINGOUT, result);
            return !result.get();
        } finally {
            Thread.currentThread().setContextClassLoader(oldCL);
        }
    }
    return true;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:32,代码来源:AsyncContextImpl.java

示例14: testDumpEphemerals

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
/**
 * For ZOOKEEPER-1755 - Test race condition when taking dumpEphemerals and
 * removing the session related ephemerals from DataTree structure
 */
@Test(timeout = 60000)
public void testDumpEphemerals() throws Exception {
    int count = 1000;
    long session = 1000;
    long zxid = 2000;
    final DataTree dataTree = new DataTree();
    LOG.info("Create {} zkclient sessions and its ephemeral nodes", count);
    createEphemeralNode(session, dataTree, count);
    final AtomicBoolean exceptionDuringDumpEphemerals = new AtomicBoolean(
            false);
    final AtomicBoolean running = new AtomicBoolean(true);
    Thread thread = new Thread() {
        public void run() {
            PrintWriter pwriter = new PrintWriter(new StringWriter());
            try {
                while (running.get()) {
                    dataTree.dumpEphemerals(pwriter);
                }
            } catch (Exception e) {
                LOG.error("Received exception while dumpEphemerals!", e);
                exceptionDuringDumpEphemerals.set(true);
            }
        };
    };
    thread.start();
    LOG.debug("Killing {} zkclient sessions and its ephemeral nodes", count);
    killZkClientSession(session, zxid, dataTree, count);
    running.set(false);
    thread.join();
    Assert.assertFalse("Should have got exception while dumpEphemerals!",
            exceptionDuringDumpEphemerals.get());
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:37,代码来源:DataTreeTest.java

示例15: open

import java.util.concurrent.atomic.AtomicBoolean; //导入方法依赖的package包/类
/**
 * Open a modal dialog to specify a new Scope.
 * 
 * @param title - the title of the dialog
 * @param scope - the scope to use to preselect parts
 * @return a new Scope or null if the dialog was canceled
 */
public static Scope open(String title, final Scope scope) {
    final CustomScopePanel panel = new CustomScopePanel();
    final AtomicBoolean successful = new AtomicBoolean();

    DialogDescriptor dialogDescriptor = new DialogDescriptor(
            panel,
            title,
            true, // modal
            new Object[]{DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION},
            DialogDescriptor.CANCEL_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == DialogDescriptor.OK_OPTION) {
                successful.set(true);
            }
        }
    });

    dialogDescriptor.setClosingOptions(new Object[]{DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION});

    new Thread(new Runnable() {

        @Override
        public void run() {
            panel.initialize(scope);
        }
    }).start();
    
    DialogDisplayer.getDefault().createDialog(dialogDescriptor).setVisible(true);
    
    if(successful.get()) {
        return panel.getCustomScope();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:JavaScopeBuilder.java


注:本文中的java.util.concurrent.atomic.AtomicBoolean.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。