public void removePackage(String packageName) { synchronized (this) { mPackages.remove(packageName); } }
@Override public boolean remove(Object key) { if (containsKey(key)) { WeakHashMap.this.remove(key); return true; } return false; }
public static void clearCache(ClassLoader loader) { if (loader == null) { throw new NullPointerException("loader == null"); } cache.remove(loader); }
/** * Removes the buffer for the current thread. */ private void removeBuffer() { Thread current = Thread.currentThread(); buffers.remove(current); }
public static void clearCache() { cache.remove(ClassLoader.getSystemClassLoader()); }
@Override public synchronized V remove(Object key) { WeakHashMap<K, V> tmp = new WeakHashMap<K, V>(map); V result = tmp.remove(key); map = Collections.unmodifiableMap(tmp); return result; }
@Override public void restore(Node node) { CacheMemento cacheMemento = cache.remove(node); if (cacheMemento != null) { cacheMemento.restore(); } } };
@Override public void binderDied() { token.unlinkToDeath(this, 0); mProxyIIntentReceivers.remove(token); } }, 0);
private static synchronized void removeTaskFromTimer(AnimatedLabel animatedLabel) { SCHEDULED_TASKS.get(animatedLabel).cancel(); SCHEDULED_TASKS.remove(animatedLabel); canCloseTimer(); }
/** * Dismiss a dialog previously shown with show(). * * @return self * */ public T dismiss(Dialog dialog){ try{ if(dialog != null){ dialogs.remove(dialog); dialog.dismiss(); } }catch(Exception e){ } return self(); }
/** * Throws LeaseExpiredException if the calling thread's lease on this lock previously expired. The * expired lease will no longer be tracked after throwing LeaseExpiredException. Caller must * synchronize on this lock token. * * @throws LeaseExpiredException if calling thread's lease expired */ void throwIfCurrentThreadHadExpiredLease() throws LeaseExpiredException { if (this.expiredLeases == null) { return; } if (this.expiredLeases.containsKey(Thread.currentThread())) { this.expiredLeases.remove(Thread.currentThread()); throw new LeaseExpiredException( "This thread's lease expired for this lock"); } }
public static void onContextDestroyed(Context context) { if (mTrackedContexts == null) { throw new RuntimeException( "onContextDestroyed called without onContextCreated for: " + context); } LeakDetector removed = mTrackedContexts.remove(context); if (removed == null) { throw new RuntimeException( "onContextDestroyed called without onContextCreated for: " + context); } else { removed.clear(); } ComponentsPools.onContextDestroyed(context); } }
@Override public void restore(Pane node) { ArrayList<Node> children = cache.remove(node); if (children != null) { node.getChildren().setAll(children); } } };
public static void unbindFromService(final ServiceToken token) { if (token == null) { return; } final ContextWrapper mContextWrapper = token.mWrappedContext; final ServiceBinder mBinder = mConnectionMap.remove(mContextWrapper); if (mBinder == null) { return; } mContextWrapper.unbindService(mBinder); if (mConnectionMap.isEmpty()) { mService = null; } }
public static void unbindFromService(final ServiceToken token) { if (token == null) { return; } final ContextWrapper mContextWrapper = token.mWrappedContext; final ServiceBinder mBinder = mConnectionMap.remove(mContextWrapper); if (mBinder == null) { return; } mContextWrapper.unbindService(mBinder); if (mConnectionMap.isEmpty()) { mService = null; } }
public void unregisterOnTrayPreferenceChangeListener( @NonNull final OnTrayPreferenceChangeListener listener) { // noinspection ConstantConditions if (listener == null) { return; } mListeners.remove(listener); if (mListeners.size() == 0) { mContext.getContentResolver().unregisterContentObserver(mObserver); // cleanup mObserver = null; mObserverThread.quit(); mObserverThread = null; } }
static AccessorClassLoader get(Class<?> type) { ClassLoader parent = getParentClassLoader(type); // 1. 最快路径: if (selfContextParentClassLoader.equals(parent)) { if (selfContextAccessorClassLoader == null) { synchronized (accessorClassLoaders) { // DCL with volatile semantics if (selfContextAccessorClassLoader == null) selfContextAccessorClassLoader = new AccessorClassLoader(selfContextParentClassLoader); } } return selfContextAccessorClassLoader; } // 2. 常规查找: synchronized (accessorClassLoaders) { WeakReference<AccessorClassLoader> ref = accessorClassLoaders.get(parent); if (ref != null) { AccessorClassLoader accessorClassLoader = ref.get(); if (accessorClassLoader != null) { return accessorClassLoader; } else { accessorClassLoaders.remove(parent); // the value has been GC-reclaimed, but still not the key (defensive sanity) } } AccessorClassLoader accessorClassLoader = new AccessorClassLoader(parent); accessorClassLoaders.put(parent, new WeakReference<>(accessorClassLoader)); return accessorClassLoader; } }
static AccessorClassLoader get(Class<?> type) { ClassLoader parent = getParentClassLoader(type); // 1. 最快路径: if (selfContextParentClassLoader.equals(parent)) { if (selfContextAccessorClassLoader == null) { synchronized (accessorClassLoaders) { // DCL with volatile semantics if (selfContextAccessorClassLoader == null) selfContextAccessorClassLoader = new AccessorClassLoader(selfContextParentClassLoader); } } return selfContextAccessorClassLoader; } // 2. 常规查找: synchronized (accessorClassLoaders) { WeakReference<AccessorClassLoader> ref = accessorClassLoaders.get(parent); if (ref != null) { AccessorClassLoader accessorClassLoader = ref.get(); if (accessorClassLoader != null) { return accessorClassLoader; } else { accessorClassLoaders.remove(parent); // the value has been GC-reclaimed, but still not the key (defensive sanity) } } AccessorClassLoader accessorClassLoader = new AccessorClassLoader(parent); accessorClassLoaders.put(parent, new WeakReference<>(accessorClassLoader)); return accessorClassLoader; } }
private void dispose(boolean finalized) { final SQLiteConnectionPool pool; synchronized (mLock) { if (mCloseGuardLocked != null) { if (finalized) { mCloseGuardLocked.warnIfOpen(); } mCloseGuardLocked.close(); } pool = mConnectionPoolLocked; mConnectionPoolLocked = null; } if (!finalized) { synchronized (sActiveDatabases) { sActiveDatabases.remove(this); } if (pool != null) { pool.close(); } } }
AcquiredConnectionStatus status = mAcquiredConnections.remove(connection); if (status == null) { throw new IllegalStateException("Cannot perform this operation "