Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantLock


    private ReentrantLock lock;

    public AlwaysLockedVaadinSession(VaadinService service) {
        super(service);
        lock = new ReentrantLock();
        lock.lock();
    }
View Full Code Here


    }

    @Test
    public void findUIDoesntThrowNPE() {
        try {
            ReentrantLock mockLock = Mockito.mock(ReentrantLock.class);
            when(mockLock.isHeldByCurrentThread()).thenReturn(true);

            WrappedSession emptyWrappedSession = Mockito
                    .mock(WrappedSession.class);
            when(emptyWrappedSession.getAttribute("null.lock")).thenReturn(
                    mockLock);
View Full Code Here

    private UI ui;
    private Lock httpSessionLock;

    @Before
    public void setup() throws Exception {
        httpSessionLock = new ReentrantLock();
        mockServletConfig = new MockServletConfig();
        mockServlet = new VaadinServlet();
        mockServlet.init(mockServletConfig);
        mockService = mockServlet.getService();

        mockHttpSession = EasyMock.createMock(HttpSession.class);
        mockWrappedSession = new WrappedHttpSession(mockHttpSession) {
            final ReentrantLock lock = new ReentrantLock();
            {
                lock.lock();
            }

            @Override
            public Object getAttribute(String name) {
                Object res;
View Full Code Here

 
  @Override
    public void init() throws AnalysisException {
      InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
//        slaveEventTimeQueue = new SlaveEventTimeOutQueue();
        channelLock = new ReentrantLock();

        bootstrap = new ClientBootstrap(factory);

        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() {
View Full Code Here

  public Job()
  {
    jobTasks = new ArrayList<JobTask>();
    threshold = new Threshold(5000);
    trunkLock = new ReentrantReadWriteLock();
    loadLock = new ReentrantLock();
    waitlock = new ReentrantLock();
    waitToJobReset = waitlock.newCondition();
    merged = new AtomicBoolean(false);
        merging = new AtomicBoolean(false);
        exporting = new AtomicBoolean(false);
        exported = new AtomicBoolean(false);
View Full Code Here

public class TestRemoveFromParentLocking {

    private static VerticalLayout createTestComponent() {
        VaadinSession session = new VaadinSession(null) {
            private final ReentrantLock lock = new ReentrantLock();

            @Override
            public Lock getLockInstance() {
                return lock;
            }
View Full Code Here

        addComponent(new Button("Cancel running future",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        log.clear();
                        final ReentrantLock interruptLock = new ReentrantLock();

                        final Future<Void> future = access(new Runnable() {
                            @Override
                            public void run() {
                                log("Waiting for thread to start");
                                while (!interruptLock.isLocked()) {
                                    try {
                                        Thread.sleep(100);
                                    } catch (InterruptedException e) {
                                        log("Premature interruption");
                                        throw new RuntimeException(e);
                                    }
                                }

                                log("Thread started, waiting for interruption");
                                try {
                                    interruptLock.lockInterruptibly();
                                } catch (InterruptedException e) {
                                    log("I was interrupted");
                                }
                            }
                        });

                        new Thread() {
                            @Override
                            public void run() {
                                interruptLock.lock();
                                // Wait until UI thread has started waiting for
                                // the lock
                                while (!interruptLock.hasQueuedThreads()) {
                                    try {
                                        Thread.sleep(100);
                                    } catch (InterruptedException e) {
                                        throw new RuntimeException(e);
                                    }
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  public void init() throws ServiceException {
    timersSize = getServiceConfig().getInt(CONF_TIMERS_SIZE, 10);
    counterLock = new ReentrantLock();
    timerLock = new ReentrantLock();
    variableLock = new ReentrantLock();
    samplerLock = new ReentrantLock();
    jvmVariables = new ConcurrentHashMap<String, VariableHolder>();
    counters = new ConcurrentHashMap<String, Map<String, AtomicLong>>();
    timers = new ConcurrentHashMap<String, Map<String, Timer>>();
    variables = new ConcurrentHashMap<String, Map<String, VariableHolder>>();
    samplers = new ConcurrentHashMap<String, Map<String, Sampler>>();
View Full Code Here

    if (avPointer == 0) {
      throw new ToxException(ToxError.TOX_UNKNOWN);
    }

    this.avPointer = avPointer;
    this.lock = new ReentrantLock();
    validPointers.add(pointer);
    validPointers.add(avPointer);
    instanceLock.lock();

    try {
View Full Code Here

     * @param lock    lock to use
     */
    public Promise(String name, ExceptionChainer<T> chainer, ReentrantLock lock) {
        this.name = name;
        this.chainer = chainer;
        this.lock = lock == null ? new ReentrantLock() : lock;
        this.cond = this.lock.newCondition();
    }
View Full Code Here

TOP

Related Classes of java.util.concurrent.locks.ReentrantLock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.