Called from the wizard on finish.

@param monitor the progress monitor
@throws CoreException thrown when the project creation or configuration failed
@throws InterruptedException thrown when the user canceled the project creation
968464
public void performFinish(IProgressMonitor monitor) throws CoreException, InterruptedException {
		final SubMonitor subMonitor = SubMonitor.convert(monitor, 4);
		try {
			monitor.beginTask(NewWizardMessages.NewJavaProjectWizardPageTwo_operation_create, 3);
			if (this.currProject == null) {
				updateProject(subMonitor.newChild(1));
			}

			final String newProjectCompliance = this.keepContent ? null : this.firstPage.getCompilerCompliance();
			configureJavaProject(newProjectCompliance, subMonitor.newChild(1));
		} catch (Throwable e) {
			if (this.currProject != null) {
				removeProvisonalProject();
			}
			throw e;
		} finally {
			subMonitor.done();
			this.currProject = null;
			if (this.isAutobuild != null) {
				CoreUtility.setAutoBuilding(this.isAutobuild.booleanValue());
				this.isAutobuild = null;
			}
		}
	}
1310685
void stopAfter(int remainingScans) {
		Thread thread;
		synchronized (this.monitor) {
			thread = this.watchThread;
			if (thread != null) {
				this.remainingScans.set(remainingScans);
				if (remainingScans <= 0) {
					thread.interrupt();
				}
			}
			this.watchThread = null;
		}
		if (thread != null && Thread.currentThread() != thread) {
			try {
				thread.join();
			}
			catch (InterruptedException ex) {
				Thread.currentThread().interrupt();
			}
		}
	}
1307410
public void run(IProgressMonitor monitor) {

    log.fine("Build jar");
    JarPackageData jarrer = new JarPackageData();

    jarrer.setExportJavaFiles(true);
    jarrer.setExportClassFiles(true);
    jarrer.setExportOutputFolders(true);
    jarrer.setOverwrite(true);

    try {
      // IJavaProject project =
      // (IJavaProject) resource.getProject().getNature(JavaCore.NATURE_ID);

      // check this is the case before letting this method get called
      Object element = resource.getAdapter(IJavaElement.class);
      IType type = ((ICompilationUnit) element).findPrimaryType();
      jarrer.setManifestMainClass(type);

      // Create a temporary JAR file name
      File baseDir = Activator.getDefault().getStateLocation().toFile();

      String prefix =
          String.format("%s_%s-", resource.getProject().getName(), resource
              .getName());
      File jarFile = File.createTempFile(prefix, ".jar", baseDir);
      jarrer.setJarLocation(new Path(jarFile.getAbsolutePath()));

      jarrer.setElements(resource.getProject().members(IResource.FILE));
      IJarExportRunnable runnable =
          jarrer.createJarExportRunnable(Display.getDefault()
              .getActiveShell());
      runnable.run(monitor);

      this.jarFile = jarFile;

    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
1206789
protected void awaitTasksTermination()
   {
      delegated.shutdown();
      try
      {
         delegated.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
      }
      catch (InterruptedException e)
      {
         LOG.warn("Termination has been interrupted");
      }
   }
1206507
public void stop() {
		if (!PlatformUI.isWorkbenchRunning())
			return;
		final IWorkbench workbench = PlatformUI.getWorkbench();
		final Display display = workbench.getDisplay();
		display.syncExec(new Runnable() {
			public void run() {
				if (!display.isDisposed())
					workbench.close();
			}
		});
	}
434791
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity",
		"checkstyle:returncount", "checkstyle:magicnumber"})
	public boolean compile(IProgressMonitor progress) {
		final IProgressMonitor monitor = progress == null ? new NullProgressMonitor() : progress;
		try {
			monitor.beginTask(Messages.SarlBatchCompiler_42, 18);
			if (!checkConfiguration(monitor)) {
				return false;
			}
			monitor.worked(1);
			final ResourceSet resourceSet = this.resourceSetProvider.get();
			configureExtraLanguageGenerators();
			if (!configureWorkspace(resourceSet, monitor)) {
				return false;
			}
			if (getLogger().isDebugEnabled()) {
				getLogger().debug(Utils.dump(getGeneratorConfig(), false));
			}
			monitor.worked(2);
			monitor.subTask(Messages.SarlBatchCompiler_43);
			if (this.generatorConfigProvider instanceof GeneratorConfigProvider) {
				((GeneratorConfigProvider) this.generatorConfigProvider).install(resourceSet, getGeneratorConfig());
			}
			if (monitor.isCanceled()) {
				return false;
			}
			if (this.generatorConfigProvider2 instanceof GeneratorConfigProvider2) {
				((GeneratorConfigProvider2) this.generatorConfigProvider2).install(resourceSet, getGeneratorConfig2());
			}
			if (getLogger().isDebugEnabled()) {
				getLogger().debug(Utils.dump(getGeneratorConfig2(), false));
			}
			if (monitor.isCanceled()) {
				return false;
			}
			monitor.worked(3);
			monitor.subTask(Messages.SarlBatchCompiler_44);
			final File stubClassDirectory = createTempDir(BINCLASS_FOLDER_PREFIX);
			if (monitor.isCanceled()) {
				return false;
			}
			monitor.worked(4);
			try {
				monitor.subTask(Messages.SarlBatchCompiler_45);
				this.compilerPhases.setIndexing(resourceSet, true);
				if (monitor.isCanceled()) {
					return false;
				}
				monitor.worked(5);
				// install a type provider without index lookup for the first phase
				installJvmTypeProvider(resourceSet, stubClassDirectory, true, monitor);
				if (monitor.isCanceled()) {
					return false;
				}
				monitor.worked(6);
				loadSARLFiles(resourceSet, monitor);
				if (monitor.isCanceled()) {
					return false;
				}
				monitor.worked(7);
				final File stubSourceDirectory = createStubs(resourceSet, monitor);
				if (monitor.isCanceled()) {
					return false;
				}
				monitor.worked(8);
				if (!preCompileStubs(stubSourceDirectory, stubClassDirectory, monitor)) {
					if (monitor.isCanceled()) {
						return false;
					}
					reportInternalWarning(Messages.SarlBatchCompiler_2);
				}
				monitor.worked(9);
				if (!preCompileJava(stubSourceDirectory, stubClassDirectory, monitor)) {
					if (monitor.isCanceled()) {
						return false;
					}
					if (getLogger().isDebugEnabled()) {
						getLogger().debug(Messages.SarlBatchCompiler_3);
					}
				}
				monitor.worked(10);
			} finally {
				monitor.subTask(Messages.SarlBatchCompiler_46);
				this.compilerPhases.setIndexing(resourceSet, false);
				if (monitor.isCanceled()) {
					return false;
				}
			}
			monitor.worked(11);
			// install a fresh type provider for the second phase, so we clear all previously cached classes and misses.
			installJvmTypeProvider(resourceSet, stubClassDirectory, false, monitor);
			if (monitor.isCanceled()) {
				return false;
			}
			monitor.worked(12);
			generateJvmElements(resourceSet, monitor);
			if (monitor.isCanceled()) {
				return false;
			}
			monitor.worked(13);
			final List<Resource> validatedResources = new ArrayList<>();
			final List<Issue> issues = validate(resourceSet, validatedResources, monitor);
			if (monitor.isCanceled()) {
				return false;
			}
			if (!issues.isEmpty()) {
				if (reportCompilationIssues(issues)) {
					return false;
				}
			}
			monitor.worked(14);
			overrideXtextInternalLoggers();
			generateJavaFiles(validatedResources, monitor);
			if (monitor.isCanceled()) {
				return false;
			}
			monitor.worked(15);
			if (isJavaPostCompilationEnable()) {
				postCompileJava(monitor);
				if (monitor.isCanceled()) {
					return false;
				}
			}
			monitor.worked(16);
		} finally {
			monitor.subTask(Messages.SarlBatchCompiler_47);
			destroyClassLoader(this.jvmTypesClassLoader);
			destroyClassLoader(this.annotationProcessingClassLoader);
			if (isDeleteTempDirectory()) {
				monitor.subTask(Messages.SarlBatchCompiler_48);
				for (final File file : this.tempFolders) {
					cleanFolder(file, ACCEPT_ALL_FILTER, true, true);
				}
			}
			unconfigureExtraLanguageGenerators();
			monitor.done();
		}
		return true;
	}
756002
public void asyncOperationStarted() {
    if (syncThread == Thread.currentThread()) {
      synchronized (entry) {
        while (entry.isProcessing()) {
          try {
            entry.wait();
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
        }
      }
    } else {
      entryLocked = false;
    }
  }
716601
protected SARLConfiguration readConfiguration(ProjectConfigurationRequest request,
			IProgressMonitor monitor) throws CoreException {

		SARLConfiguration initConfig = null;
		SARLConfiguration compileConfig = null;

		final List<MojoExecution> mojos = getMojoExecutions(request, monitor);
		for (final MojoExecution mojo : mojos) {
			final String goal = mojo.getGoal();
			switch (goal) {
			case "initialize": //$NON-NLS-1$
				initConfig = readInitializeConfiguration(request, mojo, monitor);
				break;
			case "compile": //$NON-NLS-1$
				compileConfig = readCompileConfiguration(request, mojo, monitor);
				break;
			default:
			}
		}

		if (compileConfig != null && initConfig != null) {
			compileConfig.setFrom(initConfig);
		}

		return compileConfig;
	}
529579
@Override
   public void start() {
      synchronized (this) {
         try {
            while (state == ComponentStatus.INITIALIZING) {
               wait();
            }
            if (state != ComponentStatus.INSTANTIATED) {
               return;
            }

            state = ComponentStatus.INITIALIZING;
         } catch (InterruptedException e) {
            throw new CacheException("Interrupted waiting for the component registry to start");
         }
      }

      try {
         preStart();

         internalStart();

         synchronized (this) {
            state = ComponentStatus.RUNNING;
            notifyAll();
         }

         postStart();
      } catch (Throwable t) {
         synchronized (this) {
            state = ComponentStatus.FAILED;
            notifyAll();
         }

         try {
            stop();
         } catch (Throwable t1) {
            t.addSuppressed(t1);
         }

         handleLifecycleTransitionFailure(t);
      }
   }
1356628
private void manage() throws InterruptedException
  {
    log.info("Beginning management in %s.", config.getStartDelay());
    Thread.sleep(config.getStartDelay().getMillis());

    // Ignore return value- we'll get the IDs and futures from getKnownTasks later.
    taskRunner.restore();

    while (active) {
      giant.lock();

      try {
        // Task futures available from the taskRunner
        final Map<String, ListenableFuture<TaskStatus>> runnerTaskFutures = new HashMap<>();
        for (final TaskRunnerWorkItem workItem : taskRunner.getKnownTasks()) {
          runnerTaskFutures.put(workItem.getTaskId(), workItem.getResult());
        }
        // Attain futures for all active tasks (assuming they are ready to run).
        // Copy tasks list, as notifyStatus may modify it.
        for (final Task task : ImmutableList.copyOf(tasks)) {
          if (!taskFutures.containsKey(task.getId())) {
            final ListenableFuture<TaskStatus> runnerTaskFuture;
            if (runnerTaskFutures.containsKey(task.getId())) {
              runnerTaskFuture = runnerTaskFutures.get(task.getId());
            } else {
              // Task should be running, so run it.
              final boolean taskIsReady;
              try {
                taskIsReady = task.isReady(taskActionClientFactory.create(task));
              }
              catch (Exception e) {
                log.warn(e, "Exception thrown during isReady for task: %s", task.getId());
                notifyStatus(task, TaskStatus.failure(task.getId()), "failed because of exception[%s]", e.getClass());
                continue;
              }
              if (taskIsReady) {
                log.info("Asking taskRunner to run: %s", task.getId());
                runnerTaskFuture = taskRunner.run(task);
              } else {
                continue;
              }
            }
            taskFutures.put(task.getId(), attachCallbacks(task, runnerTaskFuture));
          } else if (isTaskPending(task)) {
            // if the taskFutures contain this task and this task is pending, also let the taskRunner
            // to run it to guarantee it will be assigned to run
            // see https://github.com/apache/incubator-druid/pull/6991
            taskRunner.run(task);
          }
        }
        // Kill tasks that shouldn't be running
        final Set<String> tasksToKill = Sets.difference(
            runnerTaskFutures.keySet(),
            ImmutableSet.copyOf(
                Lists.transform(
                    tasks,
                    new Function<Task, Object>()
                    {
                      @Override
                      public String apply(Task task)
                      {
                        return task.getId();
                      }
                    }
                )
            )
        );
        if (!tasksToKill.isEmpty()) {
          log.info("Asking taskRunner to clean up %,d tasks.", tasksToKill.size());
          for (final String taskId : tasksToKill) {
            try {
              taskRunner.shutdown(
                  taskId,
                  "task is not in runnerTaskFutures[%s]",
                  runnerTaskFutures.keySet()
              );
            }
            catch (Exception e) {
              log.warn(e, "TaskRunner failed to clean up task: %s", taskId);
            }
          }
        }
        // awaitNanos because management may become necessary without this condition signalling,
        // due to e.g. tasks becoming ready when other folks mess with the TaskLockbox.
        managementMayBeNecessary.awaitNanos(MANAGEMENT_WAIT_TIMEOUT_NANOS);
      }
      finally {
        giant.unlock();
      }
    }
  }
1363573
@Override
    public void onOnline(Computer c, TaskListener listener) throws IOException, InterruptedException {
        synchronized(this) {
            future.cancel(false);
            future = Timer.get().schedule(MONITOR_UPDATER, 5, TimeUnit.SECONDS);
        }
    }
1239644
public static void writeFile(IFile file, final FileOutput output, IProgressMonitor monitor) throws CoreException {

        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            output.writeFile(bos);
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            if (!file.exists()) {
                mkdirs(file, monitor);
                file.create(bis, true, monitor);
            } else {
                file.setContents(bis, true, false, monitor);
            }
        } catch (IOException e) {
            IStatus status = FindbugsPlugin.createErrorStatus("Exception while " + output.getTaskDescription(), e);
            throw new CoreException(status);
        }
    }
1351658
public void exception( ExceptionSource source, Throwable exception )
    {
        synchronized( m_monitors )
        {
            for( ExceptionMonitor monitor : m_monitors )
            {
                monitor.exception( source, exception );
            }
        }
    }
1256698
public void changeMonitor(ComponentMonitor monitor) {
		// will also change monitor in lifecycleStrategyForInstanceRegistrations
		if (componentAdapterFactory instanceof ComponentMonitorStrategy) {
			((ComponentMonitorStrategy) componentAdapterFactory).changeMonitor(monitor);
		}
		for (Iterator i = compAdapters.iterator(); i.hasNext();) {
			Object adapter = i.next();
			if (adapter instanceof ComponentMonitorStrategy) {
				((ComponentMonitorStrategy) adapter).changeMonitor(monitor);
			}
		}
		for (Iterator i = children.iterator(); i.hasNext();) {
			Object child = i.next();
			if (child instanceof ComponentMonitorStrategy) {
				((ComponentMonitorStrategy) child).changeMonitor(monitor);
			}
		}
	}
1142077
public void exit(Object monitor) {
        if (monitor == null) {
            throw new NullPointerException();
        }

        // remove last
        ListIterator it = monitors.listIterator(monitors.size());
        while (it.hasPrevious()) {
            Object prev = it.previous();
            if (monitor == prev) { // Never use equals() to test equality. We always need to make sure that the objects are the same, we
                                   // don't care if they're the objects are logically equivalent
                it.remove();
                return;
            }
        }
        
        throw new IllegalArgumentException(); // not found
    }
778650
@Handler(priority = -10000)
    public void onStop(Stop event) throws InterruptedException {
        synchronized (this) {
            if (runner == null) {
                return;
            }
            runner.interrupt();
            synchronized (this) {
                if (registered) {
                    unregisterAsGenerator();
                    registered = false;
                }
            }
            runner = null;
        }
    }
690577
public void execute() throws CheckedAnalysisException, IOException, InterruptedException {
        File dir = new File(rootSourceDirectory);
        if (!dir.isDirectory()) {
            throw new IOException("Path " + rootSourceDirectory + " is not a directory");
        }

        // Find all directories underneath the root source directory
        progress.startRecursiveDirectorySearch();
        RecursiveFileSearch rfs = new RecursiveFileSearch(rootSourceDirectory, pathname -> pathname.isDirectory());
        rfs.search();
        progress.doneRecursiveDirectorySearch();
        List<String> candidateSourceDirList = rfs.getDirectoriesScanned();

        // Build the classpath

        IClassFactory factory = ClassFactory.instance();
        IClassPathBuilder builder = factory.createClassPathBuilder(errorLogger);

        try (IClassPath classPath = buildClassPath(builder, factory)) {

            // From the application classes, find the full list of
            // fully-qualified source file names.
            List<String> fullyQualifiedSourceFileNameList = findFullyQualifiedSourceFileNames(builder, classPath);

            // Attempt to find source directories for all source files,
            // and add them to the discoveredSourceDirectoryList
            if (DEBUG) {
                System.out.println("looking for " + fullyQualifiedSourceFileNameList.size() + " files");
            }
            findSourceDirectoriesForAllSourceFiles(fullyQualifiedSourceFileNameList, candidateSourceDirList);
        }
    }