Must be called from a synchronized section
770041
private Map<String, TrackedNode<T>> trackNode(String path,
                                                Map<String, TrackedNode<T>> tree,
                                                Collection<NodeEvent<T>> events,
                                                int depth)
    throws InterruptedException, KeeperException
  {
    if(depth > _depth)
    {
      if(log.isDebugEnabled())
        log.debug(logString(path, "max depth reached ${depth}"));

      return tree;
    }

    TrackedNode<T> oldTrackedNode = tree.get(path);

    try
    {
      ZKData<T> res = _zkDataReader.readData(_zk, path, _treeWacher);

      TrackedNode<T> newTrackedNode =
        new TrackedNode<T>(path, res.getData(), res.getStat(), depth);
      if(oldTrackedNode != null)
      {
        if(!_zkDataReader.isEqual(oldTrackedNode.getData(), newTrackedNode.getData()))
        {
          events.add(new NodeEvent<T>(NodeEventType.UPDATED,
                                      newTrackedNode));
        }
      }
      else
      {
        events.add(new NodeEvent<T>(NodeEventType.ADDED,
                                    newTrackedNode));
      }

      tree.put(path, newTrackedNode);

      if(depth < _depth)
      {
        ZKChildren children = _zk.getZKChildren(path, _treeWacher);
        // the stat may change between the 2 calls
        if(!newTrackedNode.getStat().equals(children.getStat()))
          newTrackedNode.setStat(children.getStat());
        Collections.sort(children.getChildren());
        for(String child : children.getChildren())
        {
          String childPath = PathUtils.addPaths(path, child);
          if(!tree.containsKey(childPath))
            trackNode(childPath, tree, events, depth + 1);
        }
      }

      _lastZkTxId = Math.max(_lastZkTxId, newTrackedNode.getZkTxId());
      _lock.notifyAll();
      if(log.isDebugEnabled())
        log.debug(logString(path,
                            "start tracking " + (depth < _depth ? "": "leaf ") +
                            "node zkTxId=" + newTrackedNode.getZkTxId()));

    }
    catch (KeeperException.NoNodeException e)
    {
      // this is a race condition which could happen between the moment the event is received
      // and this call
      if(log.isDebugEnabled())
        log.debug(logString(path, "no such node"));
      // it means that the node has disappeared

      tree.remove(path);

      if(oldTrackedNode != null)
      {
        events.add(new NodeEvent<T>(NodeEventType.DELETED, 
                                    oldTrackedNode));
      }
    }

    return tree;
  }
228923
public void synchronize(List<? extends E> list) {
		assert SwingUtilities.isEventDispatchThread() : ApplicationResources.accessor.getMessage("assert.notRunningInSwingEventThread");

		// Make sure the first element exists and matches
		int modelOffset;
		if(constantFirstRow!=null) {
			modelOffset = 1;
			if(isEmpty()) addElement(constantFirstRow);
			else if(!getElementAt(0).equals(constantFirstRow)) {
				insertElementAt(constantFirstRow, 0);
			}
		} else modelOffset = 0;

		// Synchronize the dynamic part of the list
		int size = list.size();
		for(int index=0; index<size; index++) {
			E obj = list.get(index);
			if(index>=(size()-modelOffset)) addElement(obj);
			else if(!obj.equals(getElementAt(index+modelOffset))) {
				// Objects don't match
				// If this object is found further down the list, then delete up to that object
				int foundIndex = -1;
				for(int searchIndex = index+1; searchIndex<(size()-modelOffset); searchIndex++) {
					if(obj.equals(getElementAt(searchIndex+modelOffset))) {
						foundIndex = searchIndex;
						break;
					}
				}
				if(foundIndex!=-1) removeRange(index+modelOffset, foundIndex-1+modelOffset);
				// Otherwise, insert in the current index
				else insertElementAt(obj, index+modelOffset);
			}
		}
		// Remove any extra
		if((size()-modelOffset) > size) removeRange(size+modelOffset, size()-1);
	}
124923
public void blockTillTerminated() {
    while (!runState.compareAndSet(State.IDLE, State.REMOVED)) {
      // wait and retry
      LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
      if (Thread.currentThread().isInterrupted()) {
        runState.set(State.REMOVED);
        return;
      }
    }
  }
550922
private synchronized void synchronize() {
		personEmail = conversation.getPerson().getEmail();
		personName = conversation.getPerson().getName();
		messageCenterPendingMessage = conversation.getMessageCenterPendingMessage();
		messageCenterPendingAttachments = conversation.getMessageCenterPendingAttachments();
		hasActiveState = conversation.hasActiveState();
		messageCenterWhoCardPreviouslyDisplayed = conversation.isMessageCenterWhoCardPreviouslyDisplayed();
		unreadMessageCount = conversation.getMessageManager().getUnreadMessageCount();
	}
433164
public void execute() throws CheckedAnalysisException {
        method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
        ClassContext classContext = Global.getAnalysisCache().getClassAnalysis(ClassContext.class,
                methodDescriptor.getClassDescriptor());

        BitSet bytecodeSet = classContext.getBytecodeSet(method);
        if (bytecodeSet == null) {
            return;
        }
        if (bytecodeSet.get(Const.MONITORENTER) || bytecodeSet.get(Const.MONITOREXIT)) {
            this.lockDataflow = classContext.getLockDataflow(method);
        } else if (method.isSynchronized()) {
            this.vnaDataflow = classContext.getValueNumberDataflow(method); // will
            // need
            // this
            // later
        }
    }
1200266
public void sync() throws Exception {
        try {
            JedisClusterPipeline pipeline = new JedisClusterPipeline(clusterInfoCache);
            execute(pipeline);
            pipeline.sync();
        } catch (JedisMovedDataException jre) {
            // if MOVED redirection occurred, rebuilds cluster's slot cache,
            // recommended by Redis cluster specification
            connectionHandler.renewSlotCache();
            if (maxAttempts > 0) {
                maxAttempts--;
                sync();
                return;
            }
            throw jre;
        } catch (Exception e) {
            throw e;
        }
    }
1109428
protected void init() {
        // create a synchronisation task which makes sure that the change requested by
        // the internal future has at one time been synchronized to the remote
        synchronisationFuture = GlobalCachedExecutorService.submit(() -> {
            dataProvider.addDataObserver(notifyChangeObserver);
            try {
                dataProvider.waitForData();
                T result = internalFuture.get();
                waitForSynchronization(result);
            } catch (CouldNotPerformException ex) {
                ExceptionPrinter.printHistory("Could not sync with internal future!", ex, logger);
            } finally {
                dataProvider.removeDataObserver(notifyChangeObserver);
            }
            return null;
        });
    }
1341544
@Override
    public final void exception ( Exception e ) {
        this.error = true;
        this.exception = e;
        this.received = true;
        synchronized ( this ) {
            notifyAll();
        }
    }
865573
public static void call(Runnable task) {
        try {
            call(() -> {
                task.run();
                return true;
            });
        } catch (Exception e) {
            // It's safe to throw unsafely here because the Callable we passed never throws a checked exception.
            Exceptions.throwUnsafely(e);
        }
    }
309885
public void sync() throws ClosedJournalException, IOException {
        try {
            appender.sync().get();
            if (appender.getAsyncException() != null) {
                throw new IOException(appender.getAsyncException());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex.getMessage(), ex);
        }
    }
870152
void writeLock(int count) {
      if (count > 0 && counter != null)
         counter.acquireShared(count);
      sync.acquireShared(1);
   }
1179847
@Override
  public void resync() {
    lock.writeLock().lock();
    try {
      if (this.knownObjects == null) {
        return;
      }

      List<String> keys = this.knownObjects.listKeys();
      for (String key : keys) {
        syncKeyLocked(key);
      }
    } finally {
      lock.writeLock().unlock();
    }
  }
1076106
protected void onRPCComplete(int asyncHandle, String data) {
        IAsyncRPCEvent callback = getCallback(asyncHandle);
        
        if (callback != null) {
            callback.onRPCComplete(asyncHandle, data);
        }
    }
781457
private void syncInternal() throws IOException {
        syncCompactor();
        fireBeforePersist();
        
        /* CALLS ORDERED: Need force _segment first and then persist
         * _addressArray. During recovery, the _addressArray can always
         * point to addresses which are valid though may not reflect the
         * most recent address update.
         */
        _segment.force();
        _addressArray.sync();
        _segmentManager.updateMeta();
        
        fireAfterPersist();
    }
1014810
public synchronized void setSynced(boolean sync) {
        if (synced.get() != sync) {
            // We are changing sync state, so add or remove our master listener as appropriate.
            if (sync && isSendingStatus()) {
                addMasterListener(ourSyncMasterListener);
            } else {
                removeMasterListener(ourSyncMasterListener);
            }

            // Also, if there is a tempo master, and we just got synced, adopt its tempo.
            if (!isTempoMaster() && getTempoMaster() != null) {
                setTempo(getMasterTempo());
            }
        }
        synced.set(sync);
    }
714105
public void run()
    {
        // Note: To make sure the user gets a chance to see the
        // html text, we wait for a paint before returing.
        // Since these threads are stacked in a private thread queue, the next
        // thread is not executed until this one is finished.
            if (! EventQueue.isDispatchThread() 
)//            && Runtime.getRuntime().availableProcessors() == 1)
        {
            if (!m_syncPage.isPaintCalled())
            {   // Wait for the previous call to finish
                synchronized (m_syncPage) {
                    while (!m_syncPage.isPaintCalled()) {
                        try { m_syncPage.wait(); } catch (InterruptedException e) {}
                    }
                }
            }
            synchronized (m_syncPage) {
                m_syncPage.setPaintCalled(false);

                this.runPageLoader();

                while (!m_syncPage.isPaintCalled()) {
                    try { m_syncPage.wait(); } catch (InterruptedException e) {}
                }
                
                this.afterPageDisplay();
            }
        }
    }
301530
private void onSynchronization(Node node, EntityMetadata metadata)
    {
        DefaultTransactionResource resource = (DefaultTransactionResource) coordinator.getResource(metadata
                .getPersistenceUnit());
        if (enableFlush)
        {
            resource.onFlush();
        }
        else
        {
            resource.syncNode(node);
        }
    }