Example usage for java.lang Thread setDaemon

List of usage examples for java.lang Thread setDaemon

Introduction

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

Prototype

public final void setDaemon(boolean on) 

Source Link

Document

Marks this thread as either a #isDaemon daemon thread or a user thread.

Usage

From source file:com.adaptris.hpcc.ManagedPumpStreamHandler.java

protected Thread createPump(final InputStream is, final OutputStream os, final boolean closeWhenExhausted) {
    String name = Thread.currentThread().getName();
    final Thread result = MTF.newThread(new StreamPumper(is, os, closeWhenExhausted));
    result.setName(name);/*from  w ww  .  ja  v  a 2 s.c  o m*/
    result.setDaemon(true);
    return result;
}

From source file:com.indeed.boxcar.server.servlet.AbstractBoxcarContextListener.java

@Override
public void contextInitialized(final ServletContextEvent event) {
    final ServletContext servletContext = event.getServletContext();
    final WebApplicationContext applicationContext = WebApplicationContextUtils
            .getRequiredWebApplicationContext(servletContext);

    try {//  ww w.  j  a v  a 2 s. co m
        final int maximumRequestsPerConnection = getIntInitParameter(servletContext,
                "maximumRequestsPerConnection", 1000);
        final int servicePort = getRequiredIntInitParameter(servletContext, "servicePort");
        final int localReservedPoolSize = getIntInitParameter(servletContext, "localReservedPoolSize", 0);
        if (localReservedPoolSize < 0) {
            throw new IllegalArgumentException(
                    "localReservedPoolSize must be >= 0, but was " + localReservedPoolSize);
        }

        server = createServer(servletContext, applicationContext, servicePort, maximumRequestsPerConnection,
                localReservedPoolSize);

        final Thread isdThread = new Thread(server);
        isdThread.setDaemon(true);
        isdThread.start();
    } catch (final Exception e) {
        logger.fatal("Error initializing webapp", e);
        throw new RuntimeException("Error in JobSearchContextListener init", e);
    }
}

From source file:com.cooksys.httpserver.RequestListenerThread.java

@Override
public void run() {
    System.out.println("Listening on port " + this.serversocket);

    while (!Thread.interrupted()) {
        try {/*from  w  ww . j  ava  2 s  .  c  o m*/
            // Listen for connections
            Socket socket = this.serversocket.accept();
            System.out.println("Incoming connection from " + socket.getInetAddress());

            //setup the http connection
            HttpServerConnection conn = this.connFactory.createConnection(socket);

            // Start worker thread
            Thread t = new WorkerThread(this.httpService, conn);
            t.setDaemon(true);
            t.start();
        } catch (InterruptedIOException ex) {
            break;
        } catch (IOException e) {
            System.err.println("Connection interrupted. " + e.getMessage());
            break;
        }
    }

    //clean up socket connection before exiting thread

    System.out.println("Server thread exiting");

}

From source file:com.reactivetechnologies.platform.rest.client.AsyncClientHandlerFactoryBean.java

@PostConstruct
private void init() {
    threads = Executors.newCachedThreadPool(new ThreadFactory() {
        private int n = 0;

        @Override//from  ww  w.j  a  v a2  s. c o  m
        public Thread newThread(Runnable r) {
            Thread t = new Thread(r, "REST-AsyncClientHandler-" + (n++));
            t.setDaemon(true);
            return t;
        }
    });
}

From source file:com.android.sslload.SslLoad.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Thread requestThread = new Thread(this);
    requestThread.setDaemon(true);
    requestThread.start();//from  w  w w  . ja  v  a2s .c om

    button = new Button(this);
    button.setText("GO");
    button.setOnClickListener(this);

    setContentView(button);
}

From source file:org.nebulaframework.grid.cluster.node.services.heartbeat.HeartBeatInvoker.java

/**
 * Starts the {@code HeartBeatInvoker}//  w  ww .j a  v  a2 s.co m
 */
public void start() {

    // Check if properly initialized
    if (this.nodeId == null || this.heartBeatProxy == null) {
        throw new IllegalStateException("Not initialized");
    }

    // Start Thread
    Thread t = new Thread(this);
    t.setDaemon(true);
    t.start();
    log.debug("[HeartBeat] Invoker Started");
}

From source file:be.fgov.kszbcss.rhq.websphere.config.NamedThreadFactory.java

public Thread newThread(final Runnable runnable) {
    // The log4j MDC is stored in an InheritableThreadLocal. We need to clear it.
    Runnable runnableWrapper = new Runnable() {
        public void run() {
            Hashtable<?, ?> context = MDC.getContext();
            if (context != null) {
                context.clear();/*from  w w  w .jav  a2s.  c  o m*/
            }
            runnable.run();
        }
    };
    Thread t = new Thread(group, runnableWrapper, namePrefix + "-" + threadNumber.getAndIncrement());
    t.setDaemon(false);
    t.setUncaughtExceptionHandler(this);
    return t;
}

From source file:arena.httpclient.AbstractHttpClient.java

public void getThreaded() {
    Thread thread = new Thread(this, this.getClass().getName());
    thread.setDaemon(true);
    thread.start();/*  w  w w .  j a v  a 2s. co m*/
}

From source file:eu.flatworld.worldexplorer.layer.nltl7.NLTL7HTTPProvider.java

public NLTL7HTTPProvider() {
    LogX.log(Level.INFO, NAME + " starting");
    client = new HttpClient();

    Thread queueRunner = new Thread(this, this.getClass().getName() + "_queueRunner");
    queueRunner.setDaemon(true);
    queueRunner.start();/* w w  w.  j ava 2 s.  co  m*/
}

From source file:com.asakusafw.bulkloader.transfer.StreamFileListProvider.java

/**
 * Redirects the {@link InputStream} into the other {@link OutputStream}.
 * @param in source input stream/*ww w .j  av  a2s .  com*/
 * @param out redirect target
 * @throws IllegalArgumentException if some parameters were {@code null}
 */
protected final void redirect(InputStream in, OutputStream out) {
    if (in == null) {
        throw new IllegalArgumentException("in must not be null"); //$NON-NLS-1$
    }
    if (out == null) {
        throw new IllegalArgumentException("out must not be null"); //$NON-NLS-1$
    }
    Thread t = new StreamRedirectThread(in, out);
    t.setDaemon(true);
    t.start();
    synchronized (running) {
        running.add(t);
    }
}