/** * Run the task, which is skipped if null. * When invoked again, the task is re-run. */ public void run() { try { if (task != null) { task.execute(); } } catch (Throwable thrown) { caught(thrown); } finally { synchronized (notify) { finished = true; //reset the task. //wake up our owner, if it is waiting notify.notifyAll(); } } } }
@Override public void execute() throws BuildException { super.execute(); try { List<File> fileList = createListOfAllFilesToMerge(); // If there is nothing to merge, don't if (fileList.isEmpty()) { return; } // if the merge target doesn't exist yet, then the first file // becomes // the merge target File to = new File(into); if (!to.exists()) { File from = fileList.remove(0); copyFile(from, to); } // If there was only one file, and it has been copied as // the merge target then you're done if (fileList.isEmpty()) { return; } UnionResults.main(createCommandArgumentsArray(fileList)); } catch (Exception e) { throw new BuildException(e); } }
/** * Executes the real object if it's a task. If it's not a task * (e.g. a data type) then this method does nothing. */ public void execute() { if (realThing == null) { // Got here if the runtimeconfigurable is not enabled. return; } try { if (realThing instanceof Task) { ((Task) realThing).execute(); } } finally { // Finished executing the task // null it (unless it has an ID) to allow // GC do its job // If this UE is used again, a new "realthing" will be made if (getWrapper().getId() == null) { realThing = null; getWrapper().setProxy(null); } } }
public class TaskRunner implements Runnable { private BlockingQueue<Task> queue; public TaskRunner(BlockingQueue<Task> queue) { this.queue = queue; } public void run() { try { while (true) { Task task = queue.take(10, TimeUnit.SECONDS); task.execute(); } } catch (InterruptedException e) { // Restore the interrupted status Thread.currentThread().interrupt(); } } }
public U execute(V input) { Object object = input; for (Task task : taskList) object = task.execute(object); return (U) object; }
public void run() { this.task.execute(); } }
public static void main(String[] args) { for (final Task task : tasks) { try{ task.execute(); } catch (Exception e) { e.printStackTrace(); } } }
public void stop() throws Exception { // Stop XWiki if it was started by start() if (!this.wasStarted) { createStopTask().execute(); } }
/** * {@inheritDoc} * * @see junit.extensions.TestSetup#tearDown() */ @Override protected void tearDown() throws Exception { // Stop XWiki createStopTask().execute(); } }
public void stop() throws Exception { // Stop XWiki if it was started by start() if (!this.wasStarted) { createStopTask().execute(); } }
Task task = new Task(){ @Override protected void onPostExecute(Result result) { super.onPostExecute(result); //handle your result here } }; task.execute();
@Override public void execute() throws BuildException { super.execute(); if (this.filter == null) { throw new BuildException("must supply a filter glob"); } try { analyse(); } catch (final IOException e) { throw new BuildException(e); } }
@Override public void execute() throws BuildException { try { FlowUtils.createFlowDeletionPack(sourcePath, destinationPath); } catch (IOException e) { e.printStackTrace(); throw new BuildException(e); } super.execute(); }
ExecutorService pool = Executors.newFixedThreadPool(10); for(final Task task: tasks) { pool.execute(new Runnable() { @Override public void run() { task.execute(); } }); } pool.shutdown(); while(!pool.awaitTermination(1, TimeUnit.SECONDS)) { System.out.println("Waiting for tasks to shutdown"); }
@Override public void execute() throws BuildException { try { FlowUtils.createRetrieveAllFlowsManifest(destinationPath); } catch (IOException e) { e.printStackTrace(); throw new BuildException(e); } super.execute(); }
@Override public void execute() throws BuildException { try { FlowUtils.createFlowInactivation(sourcePath, destinationPath, destructiveChanges); } catch (IOException e) { e.printStackTrace(); throw new BuildException(e); } super.execute(); }
@Override public void execute() throws BuildException { super.execute(); System.out.println("Path List:"); for (String el : paths.list()) { System.out.println("Path element is " + el); } }
@Override final public void execute() throws BuildException { super.execute(); setContextClassLoader(); try { executeInternal(); }catch(Exception e) { error(e); throw new BuildException(e); } }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { final Task task = new Task(); task.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (Task.ROW_COUNT.equals(evt.getPropertyName())) { int rowCount = task.getRowCount(); // do what you need with rowCount here } } }); task.execute(); // again I usually call this here }
Task t=new Task(); Task t1=new Task(); Task t2=new Task(); t.setNext(t1); t1.setNext(t2); t.execute();