void trimList(List list, int max) { synchronized (list) { while (list.size() > max) { list.remove(0); } } }
/** * Removes a specific <tt>UserCapsNodeListener</tt> from the list of * <tt>UserCapsNodeListener</tt>s interested in events notifying about changes in the list of user * caps nodes of this <tt>EntityCapsManager</tt>. * * @param listener the <tt>UserCapsNodeListener</tt> which is no longer interested in events * notifying about changes in the list of user caps nodes of this <tt>EntityCapsManager</tt> */ public void removeUserCapsNodeListener(UserCapsNodeListener listener) { if (listener != null) { synchronized (userCapsNodeListeners) { userCapsNodeListeners.remove(listener); } } }
/** * Expires a specific <tt>Content</tt> of this <tt>Conference</tt> (i.e. if the specified * <tt>content</tt> is not in the list of <tt>Content</tt>s of this <tt>Conference</tt>, does * nothing). * * @param content the <tt>Content</tt> to be expired by this <tt>Conference</tt> */ public void expireContent(Content content) { boolean expireContent; synchronized (contents) { if (contents.contains(content)) { contents.remove(content); expireContent = true; } else expireContent = false; } if (expireContent) content.expire(); }
/* * unlocks the global lock and notifies the first waiting thread that they * now have the lock */ private static void unlock() { Thread waitingThread = null; Object loader = null; synchronized (BundleLoader.class) { lockCount--; if (lockCount != 0) return; if (waitingList.isEmpty()) { lockThread = null; return; } Object[] waiting = (Object[]) waitingList.get(0); waitingThread = (Thread) waiting[0]; loader = waiting[1]; } synchronized (loader) { synchronized (BundleLoader.class) { lockThread = waitingThread; waitingList.remove(0); loader.notifyAll(); } } }