List of usage examples for java.lang Thread join
public final void join() throws InterruptedException
From source file:de.slub.fedora.oai.OaiHarvesterTestIT.java
private void runAndWait(TerminateableRunnable runnable) throws InterruptedException { Thread thread = new Thread(runnable); thread.start();//from ww w . j a v a 2 s. c om TimeUnit.MILLISECONDS.sleep(1000); runnable.terminate(); thread.join(); }
From source file:com.agileapes.couteau.maven.mojo.AbstractPluginExecutor.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { ClassUtils.overrideThreadContextClassLoader(getProjectClassLoader()); final List<PluginTask<?>> tasks = sortTasks(getTasks()); final ThreadPoolTaskManager taskManager = new ThreadPoolTaskManager("TaskManager", getWorkers(), true); for (PluginTask task : tasks) { //noinspection unchecked task.setPluginExecutor(this); taskManager.schedule(task);//from ww w .j a va 2 s .c om } final Thread taskManagerThread = new Thread(taskManager); taskManagerThread.start(); try { taskManagerThread.join(); } catch (InterruptedException e) { throw new MojoExecutionException("Failed to carry out tasks properly", e); } }
From source file:com.espertech.esper.multithread.TestMTContextTemporalStartStop.java
private void trySend() throws Exception { epService.getEPAdministrator()/*from w w w .j a v a2 s . c o m*/ .createEPL("create context EverySecond as start (*, *, *, *, *, *) end (*, *, *, *, *, *)"); epService.getEPAdministrator().createEPL("context EverySecond select * from SupportBean"); TimerRunnable timerRunnable = new TimerRunnable(epService, 0, 24 * 60 * 60 * 1000, 1000); Thread timerThread = new Thread(timerRunnable, "timer"); EventRunnable eventRunnable = new EventRunnable(epService, 1000000); Thread eventThread = new Thread(eventRunnable, "event"); timerThread.start(); eventThread.start(); timerThread.join(); eventThread.join(); assertNull(eventRunnable.getException()); assertNull(timerRunnable.getException()); }
From source file:com.espertech.esper.multithread.TestMTStmtFilterSubquery.java
public void tryStreamFilterSubquery() throws Exception { String epl = "select * from SupportBean(not exists (select * from SupportBean_S0.win:keepall() mw where mw.p00 = 'E'))"; engine.getEPAdministrator().createEPL(epl); Thread insertThread = new Thread(new InsertRunnable(engine, 1000)); Thread filterThread = new Thread(new FilterRunnable(engine, 1000)); log.info("Starting threads"); insertThread.start();/*from w w w . j a v a 2 s . c om*/ filterThread.start(); log.info("Waiting for join"); insertThread.join(); filterThread.join(); engine.getEPAdministrator().destroyAllStatements(); }
From source file:com.meghnasoft.async.AbstractAsynchronousAction.java
/** * Return the taskOutput created by the <code>asynchronousActionPerfomed</code> * method.Returns null if either the executing background thread or * the current thread was interrupted before a taskOutput was produced. * * @return the taskOutput created by the <code>asynchronousActionPerfomed</code> * method/* w w w . j a v a 2 s. c o m*/ */ public Object getTaskOutputBlocking() { final Thread t = threadVar.getThread(); if (t == null) { return getTaskOutput(); } try { t.join(); return getTaskOutput(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return null; } }
From source file:com.thed.plugin.QtpZephyrInterceptor.java
/** * This method the ZBot agent real-time status to <b>'Batch execution completed'</b>. * The completion of batch is logged for inspection. *//* www. ja va2 s . c o m*/ public void batchEnd() { if (testcaseBatchExecution.isParallelExecution()) { for (Thread t : threads) { try { logger.info("Waiting for all the testcases to finish..."); t.join(); /** * provide implementation */ } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } System.out.println("All Done ..."); super.batchEnd(); }
From source file:com.espertech.esper.multithread.TestMTStmtFilterSubquery.java
public void tryNamedWindowFilterSubquery() throws Exception { engine.getEPAdministrator().createEPL("create window MyWindow.win:keepall() as SupportBean_S0"); engine.getEPAdministrator().createEPL("insert into MyWindow select * from SupportBean_S0"); String epl = "select * from pattern[SupportBean_S0 -> SupportBean(not exists (select * from MyWindow mw where mw.p00 = 'E'))]"; engine.getEPAdministrator().createEPL(epl); engine.getEPRuntime().sendEvent(new SupportBean_S0(1)); Thread insertThread = new Thread(new InsertRunnable(engine, 1000)); Thread filterThread = new Thread(new FilterRunnable(engine, 1000)); log.info("Starting threads"); insertThread.start();// w w w .j a v a 2s.co m filterThread.start(); log.info("Waiting for join"); insertThread.join(); filterThread.join(); engine.getEPAdministrator().destroyAllStatements(); }
From source file:com.microsoft.speech.tts.OxfordAuthentication.java
public OxfordAuthentication(String clientId, String clientSecret) { this.clientId = clientId; this.clientSecret = clientSecret; /*//from w ww.j ava 2 s .c o m * If clientid or client secret has special characters, encode before sending request */ try { this.request = String.format("grant_type=client_credentials&client_id=%s&client_secret=%s&scope=%s", URLEncoder.encode(clientId, charsetName), URLEncoder.encode(clientSecret, charsetName), URLEncoder.encode("https://speech.platform.bing.com", charsetName)); } catch (Exception e) { e.printStackTrace(); } Thread th = new Thread(new Runnable() { @Override public void run() { RenewAccessToken(); } }); try { th.start(); th.join(); } catch (Exception e) { e.printStackTrace(); } // renew the token every specified minutes accessTokenRenewer = new Timer(); nineMinitesTask = new TimerTask() { public void run() { RenewAccessToken(); } }; accessTokenRenewer.schedule(nineMinitesTask, RefreshTokenDuration, RefreshTokenDuration); }
From source file:com.workplacesystems.queuj.process.seam.SeamTransaction.java
@Observer("processTransactionSuccess") public void transactionSuccess(final TransactionContext context) { if (context.obsolete) return;//from ww w . ja va 2 s .c o m context.obsolete = true; log.debug("Commiting transaction " + context.transactionId); FilterableArrayList<ProcessServer> processServers = new FilterableArrayList<ProcessServer>(); for (ProcessWrapper process : context.processes) { ProcessServer ps = process.getContainingServer(); if (!processServers.contains(ps)) processServers.add(ps); } for (ProcessServer ps : processServers) ((ProcessImplServer) ps).commit(); for (Callback<Void> commitCallback : context.commitCallbacks) { try { commitCallback.action(); } catch (Exception e) { new QueujException(e); } } final Callback<Void> async = QueujFactory.getAsyncCallback(new Callback<Void>() { @Override protected void doAction() { for (final ProcessWrapper process : context.startProcesses) { if (process.rescheduleRequired(false)) process.interruptRunner(); else process.start(); } for (final ProcessWrapper process : context.processes) { process.callListeners(); } } }); Thread thread = new Thread(new Runnable() { public void run() { async.action(); } }); thread.start(); try { thread.join(); } catch (InterruptedException ie) { } EntityManager em = (EntityManager) Component.getInstance("entityManager"); em.clear(); }
From source file:es.uma.lcc.tasks.DecryptionRequestTask.java
private void handleAuthenticationError() { System.out.println("retrying"); mIsFirstRun = false;/*from w ww . j a v a2 s .c om*/ Thread t = new CookieRefresherThread(AccountManager.get(mMainActivity), mMainActivity); t.start(); try { t.join(); (new DecryptionRequestTask(mPicId, mSrc, mMainActivity, false)).execute(); } catch (InterruptedException e) { e.printStackTrace(); } }