Creates a new thread with the given Runnable, marks it daemon, sets the name, starts it and returns the started
thread.

@param runnable
@param threadName the thread name.
@return the started thread.
515506
public static Thread go(Runnable runnable, String threadName) {
        Thread thread = daemonThreadFrom(runnable);
        thread.setName(threadName);
        thread.start();
        return thread;
    }
528141
public Thread newThread(Runnable r) {
        Thread t;
        if (threadGroup == null) {
            t = new Thread(r, threadBaseName + threadCounter.incrementAndGet());
            t.setDaemon(isDaemon);
        } else {
            t = new Thread(threadGroup, r, threadBaseName + threadCounter.incrementAndGet());
            t.setDaemon(isDaemon);
        }
        return t;
    }
1072317
@Override
    public Thread newThread(final Runnable r) {
        final Thread t = new Thread(r, threadNamePrefix + threadIdx.getAndIncrement());
        t.setDaemon(daemon);
        return t;
    }
654603
public synchronized Thread startThread(String name) throws IllegalThreadStateException
	{
		if (!running)
		{
			log.info("[Daemon] {startThread} Starting thread " + name);
			this.running = true;
			thisThread = new Thread(this, name);
			thisThread.setDaemon(shouldStartAsDaemon()); // Set whether we're a daemon thread (false by default)
			thisThread.start();
			return thisThread;
		}
		else
		{
			throw new IllegalThreadStateException("Daemon must be stopped before it may be started");
		}
	}
1007710
def add_runnable(self, runnable):
        

        if runnable.id in self.runnables:
            raise SimError('Duplicate runnable component {0}'.format(runnable.id))

        self.runnables[runnable.id] = runnable
273607
@SuppressWarnings("static-method")
	protected Runnable createTask(Runnable runnable) {
		if (runnable instanceof JanusRunnable) {
			return runnable;
		}
		return new JanusRunnable(runnable);
	}
380784
public static ThreadFactory getThreadFactory(
            final String groupName,
            final String name,
            final int stackSize,
            final boolean incrementThreadNames,
            final Queue<String> coreList) {
        ThreadGroup group = null;
        if (groupName != null) {
            group = new ThreadGroup(Thread.currentThread().getThreadGroup(), groupName);
        }
        final ThreadGroup finalGroup = group;

        return new ThreadFactory() {
            private final AtomicLong m_createdThreadCount = new AtomicLong(0);
            private final ThreadGroup m_group = finalGroup;
            @Override
            public synchronized Thread newThread(final Runnable r) {
                final String threadName = name +
                        (incrementThreadNames ? " - " + m_createdThreadCount.getAndIncrement() : "");
                String coreTemp = null;
                if (coreList != null && !coreList.isEmpty()) {
                    coreTemp = coreList.poll();
                }
                final String core = coreTemp;
                Runnable runnable = new Runnable() {
                    @Override
                    public void run() {
                        if (core != null) {
                            // Remove Affinity for now to make this dependency dissapear from the client.
                            // Goal is to remove client dependency on this class in the medium term.
                            //PosixJNAAffinity.INSTANCE.setAffinity(core);
                        }
                        try {
                            r.run();
                        } catch (Throwable t) {
                            new VoltLogger("HOST").error("Exception thrown in thread " + threadName, t);
                        } finally {
                            m_threadLocalDeallocator.run();
                        }
                    }
                };

                Thread t = new Thread(m_group, runnable, threadName, stackSize);
                t.setDaemon(true);
                return t;
            }
        };
    }
1322940
public static Thread getThread(Runnable runnable, String name){
        return doThread(runnable, name, DefaultThreadDeamon);
    }
392069
public ServerListenerBuilder addStoppingCallback(Runnable runnable) {
        requireNonNull(runnable, "runnable");
        serverStoppingCallbacks.add(unused -> runnable.run());
        return this;
    }
218547
public <T extends Runnable> T executeSync(T runnable) {
		synchronized (runnable) {
			this.executeAsync(runnable);
			try {
				runnable.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

		return runnable;
	}
1270435
public static <T> T newInstance(final String className) {
		try {
			return (T) Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();
		} catch (final Exception e) {
			throw new RuntimeException(e);
		}

	}
838519
public static Thread newThread(Runnable runnable, String name) {
		final Thread t = newThread(runnable, name, false);
		if (t.getPriority() != Thread.NORM_PRIORITY) {
			t.setPriority(Thread.NORM_PRIORITY);
		}
		return t;
	}
585992
protected Thread newThread(Runnable task) {
    Thread result = new Thread(wrapTask(task));
    result.setDaemon(true);
    return result;
  }
956874
public static void runOnUiThread(@NonNull final Runnable runnable) {
        Condition.INSTANCE.ensureNotNull(runnable, "The runnable may not be null");
        new Handler(Looper.getMainLooper()).post(runnable);
    }
235015
static ThreadFactory createThreadFactoryBuilder(final String baseName, final String componentName) {

      StringBuilder buf = new StringBuilder("ACP:");
      if(!Strings.isNullOrEmpty(baseName)) {
         buf.append(baseName).append(":").append(componentName);
      } else {
         buf.append(componentName);
      }

      buf.append("-Thread-%d");
      return new ThreadFactoryBuilder().setNameFormat(buf.toString()).build();
   }
180182
@SneakyThrows
    public void start(final String name) {
        thread = new Thread(this);
        thread.setName(name);
        thread.start();
    }
555352
private Runnable createRunnableL7dLoggingTask(final Level level,
            final String key, final Object[] params, final Throwable t) {
        // While logging, the logger thread temporarily disguises itself as its caller.
        final String callerThreadName = Thread.currentThread().getName();

        final Runnable runnableLoggingTask = new Runnable() {
            @Override
            public void run() {
                Thread loggerThread = Thread.currentThread();
                loggerThread.setName(callerThreadName);
                try {
                    m_logger.l7dlog(level, key, params, t);
                } catch (Throwable t) {
                    System.err.println("Exception thrown in logging thread for " +
                            callerThreadName + ":" + t);
                } finally {
                    loggerThread.setName(ASYNCH_LOGGER_THREAD_NAME);
                }
            }
        };
        return runnableLoggingTask;
    }