Example usage for java.lang Thread start

List of usage examples for java.lang Thread start

Introduction

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

Prototype

public synchronized void start() 

Source Link

Document

Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.

Usage

From source file:TransitionDetectorMain.java

private static Thread startFalseWaiter(final TransitionDetector td, String name) {

    Runnable r = new Runnable() {
        public void run() {
            try {
                while (true) {
                    print("about to wait for true-to-" + "false transition, td=" + td);

                    td.waitForTrueToFalseTransition();

                    print("just noticed for true-to-" + "false transition, td=" + td);
                }/*from w w w.j  a va 2  s .c  o m*/
            } catch (InterruptedException ix) {
                return;
            }
        }
    };

    Thread t = new Thread(r, name);
    t.start();

    return t;
}

From source file:Main.java

/**
 * Starts the given {@link Runnable} tasks as daemons
 * //from  ww  w  .java2  s  .  co  m
 * @param tasks
 */
public static void startDaemon(Runnable... tasks) {
    for (Runnable task : tasks) {
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.setPriority(Thread.NORM_PRIORITY);
        thread.start();
    }
}

From source file:Main.java

public static void startOrdered(Thread t) {
    startLock.lock();//w  w w .j  av  a 2 s . co  m

    try {
        // [HB] System.out.println("\t start:"+t);
        t.start();
        // [HB] System.out.println("\t started:"+t);
    } finally {
        startLock.unlock();
    }

}

From source file:Main.java

public static Thread performOnBackgroundThread(final Runnable runnable) {
    final Thread t = new Thread() {
        @Override/*from w w  w  .  j a va  2 s.co  m*/
        public void run() {
            runnable.run();
        }
    };
    t.start();
    return t;
}

From source file:Main.java

public static void runAfter(int msSeconds, Thread thread) {
    try {//from w w w .j a  v  a 2s  .  c  o  m
        Thread.sleep(msSeconds);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    thread.start();
}

From source file:com.carl.interesting.StartINGServer.java

/**
 * Mapping MEMORY_MAP_FILE into memory for communicating with external.
 * //from w  w w .  j  av  a2  s.  c  o  m
 * @throws IOException [explain parameter]
 * @return void [explain return type]
 * @exception throws [exception type] [explain exception]
 * @see [class,class#method,class#member]
 */
private static void initServer() throws IOException {
    BASE = KeyConstant.MICROSERVICE_HOST;
    PORT = Integer.parseInt(KeyConstant.MICROSERVICE_PORT);
    Thread messageThread = new MessageTask();
    messageThread.setName("messageThread");
    messageThread.start();
}

From source file:io.seldon.clustering.recommender.jdo.AsyncClusterCountFactory.java

private static AsyncClusterCountStore create(String client, int qtimeoutSecs, int batchSize, int qSize,
        int dbRetries, double decay, boolean useDBTime) {
    AsyncClusterCountStore q = new AsyncClusterCountStore(client, qtimeoutSecs, batchSize, qSize, dbRetries,
            decay, useDBTime);/*from w w  w  . j  ava  2  s. co m*/
    Thread t = new Thread(q);
    t.start();
    return q;
}

From source file:Main.java

public static Thread runOnBackgroundThread(final Runnable runnable) {
    final Thread t = new Thread() {
        @Override//w  w  w.j a va  2s  .c  o  m
        public void run() {
            runnable.run();
        }
    };
    t.start();
    return t;
}

From source file:launcher.Download.java

/**
 * This method downloads a file from the URL specified by calling fileDownload and updates the GUI in a new thread
 * @param fileurl The URL that the download needs to occur
 * @see fileDownload/*from w w w  . j ava 2s. c om*/
 * 
 */
public static void fileGUIdownload(final String fileurl) {
    Runnable runner = new Runnable() {
        public void run() {
            try {
                Download.fileDownload(fileurl);
            } catch (IOException ex) {
                Logger.getLogger(mainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    };
    Thread t = new Thread(runner, "Code Executer");
    t.start();
}

From source file:org.pepstock.jem.node.HttpsInternalSubmitter.java

/**
 * Starts the HTTP listener, setting the handlers and SSL factory.
 * /*from  ww w.j a va  2 s .c  om*/
 * @param port port to stay in listening mode
 * @throws ConfigurationException if any errors occurs
 */
public static void start(int port) throws ConfigurationException {
    // Set up the HTTP protocol processor
    HttpProcessor httpproc = HttpProcessorBuilder.create().add(new ResponseDate())
            .add(new ResponseServer("Jem/1.1")).add(new ResponseContent()).add(new ResponseConnControl())
            .build();

    // Set up request handlers
    UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
    reqistry.register(SubmitHandler.DEFAULT_ACTION, new SubmitHandler());

    // Set up the HTTP service
    HttpService httpService = new HttpService(httpproc, reqistry);
    try {
        // sets HTTPS ALWAYS, take a SSL server socket factory
        SSLServerSocketFactory sf = KeyStoreUtil.getSSLServerSocketFactory();
        // creates thread and starts it.
        Thread t = new RequestListener(port, httpService, sf);
        t.setDaemon(false);
        t.start();
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage(), e);
    }
}