Exemplo n.º 1
0
 /**
  * Finds a given import in the list
  *
  * @param imports list of imports
  * @param id
  * @param version
  * @param match
  * @return IFeatureImport or null
  */
 private IFeatureImport findImport(List imports, String id, String version, int match) {
   for (int i = 0; i < imports.size(); i++) {
     IFeatureImport iimport = (IFeatureImport) imports.get(i);
     if (iimport.getId().equals(id)) {
       if (version == null) return iimport;
       if (version.equals(iimport.getVersion()) && match == iimport.getMatch()) return iimport;
     }
   }
   return null;
 }
Exemplo n.º 2
0
  /*
   * 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();
      }
    }
  }