Replace the old model with a new one, forcing the replacement to wait
until all threads using the old model have finished using it.

@param model The new model which is being swapped in.
508740
public synchronized void replaceModel (MaxentModel model) {
	replacementThread = Thread.currentThread();
	while (!replacementCanProceed) Thread.yield();
	setter.setModel(model);
	replacementThread = null;
    }
13510
public void setRightTableModel(TableModel model)
   {
      TableModel old = m_rightTable.getModel();
      m_rightTable.setModel(model);
      firePropertyChange("rightTableModel", old, model);
   }
904972
def setModel( self, model ):
        
        if model == self._model:
            return False
            
        self._model = model
        
        if not self._record and model:
            self._record = model()
        
        if model:
            uifile = model.schema().property('uifile')
            if ( uifile ):
                self.setUiFile(uifile)
        
        self.rebuild()
        
        return True
371673
@Override
  public void replace(List list, String resourceVersion) {
    lock.writeLock().lock();
    try {
      Set<String> keys = new HashSet<>();
      for (Object obj : list) {
        String key = this.keyOf(obj);
        keys.add(key);
        this.queueActionLocked(DeltaType.Sync, obj);
      }

      if (this.knownObjects == null) {
        for (Map.Entry<String, Deque<MutablePair<DeltaType, Object>>> entry :
            this.items.entrySet()) {
          if (keys.contains(entry.getKey())) {
            continue;
          }

          Object deletedObj = null;
          MutablePair<DeltaType, Object> delta = entry.getValue().peekLast(); // get newest
          if (delta != null) {
            deletedObj = delta.getRight();
          }
          this.queueActionLocked(
              DeltaType.Deleted, new DeletedFinalStateUnknown(entry.getKey(), deletedObj));
        }

        if (!this.populated) {
          this.populated = true;
          this.initialPopulationCount = list.size();
        }
        return;
      }

      // Detect deletions not already in the queue.
      List<String> knownKeys = this.knownObjects.listKeys();
      int queueDeletion = 0;
      for (String knownKey : knownKeys) {
        if (keys.contains(knownKey)) {
          continue;
        }

        Object deletedObj = this.knownObjects.getByKey(knownKey);
        if (deletedObj == null) {
          log.warn(
              "Key {} does not exist in known objects store, placing DeleteFinalStateUnknown marker without object",
              knownKey);
        }
        queueDeletion++;
        this.queueActionLocked(
            DeltaType.Deleted, new DeletedFinalStateUnknown<>(knownKey, deletedObj));
      }

      if (!this.populated) {
        this.populated = true;
        this.initialPopulationCount = list.size() + queueDeletion;
      }
    } finally {
      lock.writeLock().unlock();
    }
  }
1316963
public void replace(BaseCell oldOne, BaseCell newOne) {
        VirtualLayoutManager layoutManager = getLayoutManager();
        if (oldOne != null && newOne != null && mGroupBasicAdapter != null && layoutManager != null) {
            int replacePosition = mGroupBasicAdapter.getPositionByItem(oldOne);
            if (replacePosition >= 0) {
                int cardIdx = mGroupBasicAdapter.findCardIdxFor(replacePosition);
                Card card = mGroupBasicAdapter.getCardRange(cardIdx).second;
                card.replaceCell(oldOne, newOne);
                mGroupBasicAdapter.replaceComponent(Arrays.asList(oldOne), Arrays.asList(newOne));
            }
        }
    }
1353971
public void addFilterModel(final FilterModel model) {
		if (model.getUrlPatterns() != null) {
			try {
				filterLock.writeLock().lock();
				associateBundle(model.getContextModel().getVirtualHosts(), model.getContextModel().getBundle());
				for (String virtualHost : resolveVirtualHosts(model)) {
					for (String urlPattern : model.getUrlPatterns()) {
							final UrlPattern newUrlPattern = new UrlPattern(getFullPath(model.getContextModel(), urlPattern),
											model);
							String fullPath = getFullPath(model.getContextModel(), urlPattern);
							if (filterUrlPatterns.get(virtualHost) == null) {
								filterUrlPatterns.put(virtualHost, new ConcurrentHashMap<>());
							}
							Set<UrlPattern> urlSet = filterUrlPatterns.get(virtualHost).get(fullPath);
							if (urlSet == null) {
									//initialize first
									urlSet = new HashSet<>();
							}
							urlSet.add(newUrlPattern);
							filterUrlPatterns.get(virtualHost).put(fullPath, urlSet);
    //					final UrlPattern existingPattern = filterUrlPatterns.putIfAbsent(
    //							getFullPath(model.getContextModel(), urlPattern), newUrlPattern);
    //					if (existingPattern != null) {
    //						// this should never happen but is a good assertion
    //						LOG.error("Internal error (please report): Cannot associate url mapping "
    //								+ getFullPath(model.getContextModel(), urlPattern) + " to " + newUrlPattern
    //								+ " because is already associated to " + existingPattern);
    //					}
                                    }
                                }
			} finally {
				filterLock.writeLock().unlock();
			}
		}
	}
1237835
public void startUsingModel () {
	if (replacementThread != null) {
	    try { replacementThread.join(); }
	    catch (InterruptedException e) {}
	}
	replacementCanProceed = false;
	users++;
    }
248408
public void setModel(TableModel model)
    {
// Column 3 and 4: (Scroll Pane Headings)
        if (m_model != null)
            m_model.removeTableModelListener(this);
        m_model = model;
        if (model != null)
            model.addTableModelListener(this);
        this.setupPanel();      // setup a new panel
    }
726142
public final void setModel(PixelModel newModel) {
		if (newModel == null) throw new NullPointerException();
		
		if (model != newModel) {
			if (model != null)
				model.removeChangeListener(modelListener);
			model = newModel;
			model.addChangeListener(modelListener);
			update();
		}
	}
656187
public <S extends Model> int updateByModel(S model) {
        this.beforeCheck();

        Object primaryKey = AnimaUtils.getAndRemovePrimaryKey(model);

        StringBuilder sql = new StringBuilder(this.buildUpdateSQL(model, null));

        List<Object> columnValueList = AnimaUtils.toColumnValues(model, false);

        ifNotNullThen(primaryKey, () -> {
            sql.append(" WHERE ").append(this.primaryKeyColumn).append(" = ?");
            columnValueList.add(primaryKey);
        });

        return this.execute(sql.toString(), columnValueList);
    }
911718
public static void resolveVariables(Model model)
    {
        // Resolve version
        model.setVersion(resolveVersion(model));

        // Resolve groupid
        model.setGroupId(resolveGroupId(model));

        // Resolve properties
        for (Map.Entry<Object, Object> entry : model.getProperties().entrySet()) {
            if (entry.getValue() instanceof String) {
                String value = (String) entry.getValue();
                entry.setValue(value.replace("${project.version}", model.getVersion()));
            }
        }
    }
600867
def setModel(self, model):
        

        if not model:
            return

        LOGGER.debug("> Setting '{0}' model.".format(model))

        umbra.ui.views.Abstract_QTreeView.setModel(self, model)

        # Signals / Slots.
        self.model().modelAboutToBeReset.connect(self.__model__modelAboutToBeReset)
        self.model().modelReset.connect(self.__model__modelReset)
43543
public function revertModel($model)
    {
        if (!$model->is_destroy) {
            $model->destroy();
        }
        $this->pool[$model->core_name]->push($model);
    }
809777
private void updateInstructionList(InstructionModel model) {
    RouteProgress routeProgress = model.retrieveProgress();
    boolean isListShowing = instructionListLayout.getVisibility() == VISIBLE;
    rvInstructions.stopScroll();
    instructionListAdapter.updateBannerListWith(routeProgress, isListShowing);
  }
380008
function(model) {
			if (model === this._model) { return; }
			model = model || new mTextModel.TextModel();
			this._model.removeEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$
			this._model.removeEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$
			var oldLineCount = this._model.getLineCount();
			var oldCharCount = this._model.getCharCount();
			var newLineCount = model.getLineCount();
			var newCharCount = model.getCharCount();
			var newText = model.getText();
			var e = {
				type: "ModelChanging", //$NON-NLS-1$
				text: newText,
				start: 0,
				removedCharCount: oldCharCount,
				addedCharCount: newCharCount,
				removedLineCount: oldLineCount,
				addedLineCount: newLineCount
			};
			this.onModelChanging(e);
			this._model = model;
			e = {
				type: "ModelChanged", //$NON-NLS-1$
				start: 0,
				removedCharCount: oldCharCount,
				addedCharCount: newCharCount,
				removedLineCount: oldLineCount,
				addedLineCount: newLineCount
			};
			this.onModelChanged(e); 
			this._model.addEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$
			this._model.addEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$
			this._reset();
			this._update();
		}
825903
def follow_model(self, model):
        
        if model:
          self.models_by_name[model.__name__.lower()] = model
          signals.post_save.connect(create_or_update, sender=model)
          signals.post_delete.connect(self.remove_orphans, sender=model)
90698
def add_model(self, model):
        
        if model.identity not in self._models.keys():
            self._models[model.identity] = model
        else:
            raise ValueError("{} has already been defined".format(model.identity))