Example usage for java.lang IllegalThreadStateException IllegalThreadStateException

List of usage examples for java.lang IllegalThreadStateException IllegalThreadStateException

Introduction

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

Prototype

public IllegalThreadStateException(String s) 

Source Link

Document

Constructs an IllegalThreadStateException with the specified detail message.

Usage

From source file:Main.java

/**
 * <p>assertEventDispatchThread</p>
 *
 * @throws IllegalThreadStateException if any.
 *//*from   www.j av a2 s. c  o m*/
public static void assertEventDispatchThread() throws IllegalThreadStateException {
    if (!isEventDispatchThread()) {
        throw new IllegalThreadStateException("Not in EDT");
    }
}

From source file:Main.java

/**
 * <p>assertNotEventDispatchThread</p>
 *
 * @throws IllegalThreadStateException if any.
 *///  w w  w.  j a  va  2 s . co  m
public static void assertNotEventDispatchThread() throws IllegalThreadStateException {
    if (isEventDispatchThread()) {
        throw new IllegalThreadStateException("Is EDT");
    }
}

From source file:com.appdirect.sdk.support.FakeAppmarket.java

public void stop() {
    server.stop(0);//from w w  w  .ja  v a  2  s . c o m
    if (backgroundThreadException != null) {
        IllegalThreadStateException illegalThreadStateException = new IllegalThreadStateException(
                "One of the FakeAppMarket's request thread threw an exception. This is bad.");
        illegalThreadStateException.initCause(backgroundThreadException);
        throw illegalThreadStateException;
    }
}

From source file:de.persoapp.android.activity.dialog.AbstractGetResultDialog.java

public T askForResult(final BaseActivitySupport activity, Bundle args) {
    if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
        throw new IllegalThreadStateException("You are on the UI thread!");
    }//from w w w .  j av  a 2s .  co m

    final double id = Math.random();

    args.putDouble(ID, id);
    setArguments(args);

    mWaiter = new Waiter(id);

    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.showDialog(AbstractGetResultDialog.this, TAG);
        }
    });

    return mWaiter.getResult();
}

From source file:com.yy.kunka.core.workflow.state.ActivityStateManagerImpl.java

protected RollbackStateLocal getRollbackStateLocal() {
    RollbackStateLocal rollbackStateLocal = RollbackStateLocal.getRollbackStateLocal();
    if (rollbackStateLocal == null) {
        throw new IllegalThreadStateException(
                "Unable to perform ActivityStateManager operation, as the RollbackStateLocal instance is not set on the current thread! ActivityStateManager methods may not be called outside the scope of workflow execution.");
    }// w  ww  .j a  v a2s.c om
    return rollbackStateLocal;
}

From source file:org.bml.util.elasticconsumer.ElasticConsumer.java

@Override
public synchronized void start() {
    if (this.isAlive()) {
        IllegalThreadStateException ex = new IllegalThreadStateException(
                "ElasticConsumer: " + getLogPrefix() + " Is already alive");
        if (log.isWarnEnabled()) {
            log.warn(debug, null);//  w  ww  . j a  v a  2 s.c o  m
        }
        throw ex;
    }
    if (numWorkers > 0 && this.queueIn != null && this.threadFactory != null) {
        this.setShouldRun(true);
        final int tmpNumWorkers = numWorkers;
        for (int c = 0; c < tmpNumWorkers; c++) {
            this.addWorkerThread();
        }
    } else {
        this.setShouldRun(true);
    }
    if (this.getShouldRun()) {
        if (log.isInfoEnabled()) {
            log.info(getLogPrefix() + " MSG='SUCCESS: Passed configuration check.'");
        }
        super.start();
    } else {
        if (log.isFatalEnabled()) {
            log.fatal(getLogPrefix() + " MSG='FAILURE: Not configured correctly. FAILING SAFE.'");
        }
        doShutdown();
    }
}

From source file:com.hellblazer.process.impl.AbstractManagedProcess.java

@Override
public InputStream getStdErr() {
    try {/*  www. j av a  2 s .c  om*/
        return new FileInputStream(getStdErrFile());
    } catch (FileNotFoundException e) {
        throw new IllegalThreadStateException("Process has not been started");
    }
}

From source file:us.mn.state.health.lims.common.services.SampleAddService.java

public Panel getPanelForTest(Test test) throws IllegalThreadStateException {
    if (!xmlProcessed) {
        throw new IllegalThreadStateException("createSampleTestCollection must be called first");
    }//from   w  w w  . j av a 2s.  c om

    List<PanelItem> panelItems = panelItemDAO.getPanelItemByTestId(test.getId());

    for (PanelItem panelItem : panelItems) {
        Panel panel = panelIdPanelMap.get(panelItem.getPanel().getId());
        if (panel != null) {
            return panel;
        }
    }

    return null;
}

From source file:com.hellblazer.process.impl.AbstractManagedProcess.java

@Override
public String getStdErrTail(int numLines) throws IOException {
    if (!getStdErrFile().exists()) {
        throw new IllegalThreadStateException("Process has not been started or has already exited");
    }//from  w ww.  j a  v  a2s  .  c  o m
    List<String> lines = new ArrayList<>();
    try (ReversedLinesFileReader reader = new ReversedLinesFileReader(getStdErrFile())) {
        int linesRead = 0;
        String line;
        while (((line = reader.readLine()) != null) && (linesRead++ < numLines)) {
            lines.add(line);
        }
    }
    Collections.reverse(lines);
    StringBuilder builder = new StringBuilder();
    for (String line : lines) {
        builder.append(line);
        builder.append('\n');
    }
    return builder.toString();
}

From source file:com.hellblazer.process.impl.AbstractManagedProcess.java

@Override
public OutputStream getStdIn() {
    try {/*from  w w w  .j  a v  a  2 s.c o  m*/
        return new FileOutputStream(getStdInFile(), true);
    } catch (FileNotFoundException e) {
        throw new IllegalThreadStateException("Process has not been started or has already exited");
    }
}