Example usage for java.lang Thread join

List of usage examples for java.lang Thread join

Introduction

In this page you can find the example usage for java.lang Thread join.

Prototype

public final void join() throws InterruptedException 

Source Link

Document

Waits for this thread to die.

Usage

From source file:io.github.mmichaelis.selenium.client.provider.internal.QuitWebDriverRunnableTest.java

@Test
public void ignore_failure_on_any_other_failure_when_quitting() throws Exception {
    final Runnable runnable = new QuitWebDriverRunnable(driver);
    final Thread thread = Executors.defaultThreadFactory().newThread(runnable);
    Mockito.doThrow(webDriverException).when(driver).quit();
    thread.start();//  w w  w  .ja  va2  s .  com
    thread.join();
    verify(driver, atLeastOnce()).quit();
}

From source file:ExampleMIDlet.java

protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    // Called to destroy the MIDlet.
    System.out.println("destroyApp called - unconditional = " + unconditional);
    if (thread != null) {
        Thread bgThread = thread;
        thread = null; // Signal thread to die
        try {//from  w w  w  .java 2 s .  com
            bgThread.join();
        } catch (InterruptedException ex) {
        }
    }
    stopTimer();
}

From source file:io.github.mmichaelis.selenium.client.provider.internal.QuitWebDriverRunnableTest.java

@Test
public void ignore_failure_when_server_is_unreachable_meanwhile() throws Exception {
    final Runnable runnable = new QuitWebDriverRunnable(driver);
    final Thread thread = Executors.defaultThreadFactory().newThread(runnable);
    Mockito.doThrow(unreachableBrowserException).when(driver).quit();
    thread.start();//from ww w  . j a  v a  2  s.c o  m
    thread.join();
    verify(driver, atLeastOnce()).quit();
}

From source file:com.mdsh.test.media.encoding.process.AbstractProcess.java

/**
 * Waits for the given thread to end./*w  ww  .  jav a2s . com*/
 * <p>Note: InterruptedExceptions are caught and logged,
 * but otherwise ignored.
 * @param thread
 */
protected void waitForThread(final Thread thread) {
    try {
        thread.join();
    } catch (final InterruptedException e) {
        getLogger().debug("waiting for thread was interrupted: {}", e.toString(), e);
    }
}

From source file:com.microsoft.tfs.client.common.framework.command.ExtensionPointAsyncObjectWaiter.java

@Override
public void joinThread(final Thread thread) throws InterruptedException {
    final IAsyncObjectWaiter e = getExtension();
    if (e != null) {
        e.joinThread(thread);//from   w  w w .j a  v  a 2s.co m
    } else {
        thread.join();
    }
}

From source file:com.amazonaws.cognito.DeveloperAuthenticationProvider.java

@Override
public String refresh() {
    setToken(null);/*  w  w w  .j a v a 2 s .c  o  m*/
    // If there is a key with developer provider name in the logins map, it
    // means the app user has used developer credentials
    if (getProviderName() != null && !this.loginsMap.isEmpty()
            && this.loginsMap.containsKey(getProviderName())) {

        Log.e("Dev Auth", "Refreshing - Loginmap contains provider name");

        Foo foo = new Foo();
        Thread t = new Thread(foo);
        t.start();
        try {
            t.join();
        } catch (Exception e) {
            e.printStackTrace();
        }

        update(Global.myAccountInfo.getIdentityId(), Global.myAccountInfo.getToken());

        return Global.myAccountInfo.getToken();
    } else {

        Log.e("Dev Auth", "Refreshing - Loginmap is empty");

        this.getIdentityId();
        return null;
    }
}

From source file:edu.wustl.xipHost.caGrid.RetrieveNBIATest.java

@Test
public void testRetrieveDicomData1A() throws IOException {
    String seriesInstanceUID = "1.3.6.1.4.1.9328.50.1.4718";
    Retrieve gridRetrieve = new GridRetrieveNBIA();
    Map<Integer, Object> dicomCriteria = new HashMap<Integer, Object>();
    Map<String, Object> aimCriteria = new HashMap<String, Object>();
    dicomCriteria.put(Tag.SeriesInstanceUID, seriesInstanceUID);
    gridRetrieve.setCriteria(dicomCriteria, aimCriteria);
    gridRetrieve.setImportDir(importDir);
    GridManagerFactory.getInstance().setSelectedGridLocation(gridLoc);
    List<ObjectDescriptor> objectDescs = new ArrayList<ObjectDescriptor>();
    ObjectDescriptor objDesc1 = new ObjectDescriptor();
    Uuid objDescUUID = new Uuid();
    objDescUUID.setUuid(UUID.randomUUID().toString());
    objDesc1.setUuid(objDescUUID);/*from w  ww . j a v  a 2  s .co  m*/
    objDesc1.setMimeType("application/dicom");
    ObjectDescriptor objDesc2 = new ObjectDescriptor();
    Uuid objDescUUID2 = new Uuid();
    objDescUUID2.setUuid(UUID.randomUUID().toString());
    objDesc2.setUuid(objDescUUID2);
    objDesc2.setMimeType("application/dicom");
    objectDescs.add(objDesc1);
    objectDescs.add(objDesc2);
    gridRetrieve.setObjectDescriptors(objectDescs);
    gridRetrieve.addRetrieveListener(this);
    Thread t = new Thread(gridRetrieve);
    t.start();
    try {
        t.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    //To ensure that the right DICOM were retrieved get files, scan each of them and assert seriesInstanceUIDs
    boolean isRetrieveOK = true;
    if (objectLocators.size() == 0) {
        isRetrieveOK = false;
    }
    Iterator<String> iter = objectLocators.keySet().iterator();
    while (iter.hasNext()) {
        String key = iter.next();
        ObjectLocator objLoc = objectLocators.get(key);
        File file = new File(objLoc.getUri());
        String mimeType = DicomUtil.mimeType(file);
        if (mimeType.equalsIgnoreCase("application/dicom")) {
            parser.parse(file);
            String actualSeriesInstanceUID = parser.getSeriesInstanceUID();
            if (!actualSeriesInstanceUID.equalsIgnoreCase(seriesInstanceUID)) {
                isRetrieveOK = false;
                break;
            }
        }
    }
    assertTrue("Wrong data retrieved. See seriesInstanceUID.", isRetrieveOK);
}

From source file:org.openvpms.report.openoffice.AbstractOpenOfficeLoadTestCase.java

/**
 * Load tests the OpenOffice interface./*  w w  w.  j  a  v  a  2s. c  o  m*/
 *
 * @throws Exception for any error
 */
@Test
public void test() throws Exception {
    createCustomer(); // hack to force init of jxpath function cache to
    // avoid ConcurrentModificationException

    Thread[] threads = new Thread[10];
    Reporter[] reporters = new Reporter[threads.length];
    int count = 1000;
    for (int i = 0; i < threads.length; ++i) {
        reporters[i] = new Reporter(count);
        threads[i] = new Thread(reporters[i]);
    }
    for (Thread thread : threads) {
        thread.start();
    }

    for (Thread thread : threads) {
        thread.join();
    }
    for (Reporter reporter : reporters) {
        assertFalse(reporter.failed());
    }
}

From source file:org.echocat.jomon.spring.ContextLoadThreadGroup.java

public void join() throws InterruptedException {
    for (final Thread thread : this) {
        if (thread.isAlive()) {
            thread.join();
        }//from w  w  w  .j  av  a 2s.c o m
    }
    throwRuntimeExceptionOn();
}

From source file:com.kumarvv.setl.Setl.java

/**
 * start the process/*from w ww . j av  a  2s.  co  m*/
 * @param def
 */
protected void start(final Def def) {
    if (def == null) {
        Logger.error("Invalid or blank definition");
        return;
    }

    LoggingContext.put("defName", def.getName());
    LoggingContext.put("loadTable", "");

    Logger.info("Processing " + def.getName());

    Status status = new Status((s) -> printStatEvery(s));
    SetlProcessor processor = new SetlProcessor(status, def);
    Thread t = new Thread(processor);
    t.run();

    try {
        t.join();
    } catch (InterruptedException ie) {
    }

    printStatAll(status);
}