Examples of newThread()


Examples of java.util.concurrent.ThreadFactory.newThread()

        Thread t = factory.newThread(mock(Runnable.class));
        assertTrue(t.getName().startsWith("test "));
    }
    public void testNewThreadDelegation() throws Exception {
        ThreadFactory delegate = mock(ThreadFactory.class);
        when(delegate.newThread(any(Runnable.class))).thenReturn(new Thread("thread"));
        PrefixedThreadFactory factory = new PrefixedThreadFactory(delegate, "test ");
        Thread t = factory.newThread(mock(Runnable.class));
        verify(delegate).newThread(any(Runnable.class));
        assertEquals(t.getName(), "test thread");
    }
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

        ? builder.backingThreadFactory
        : Executors.defaultThreadFactory();
    final AtomicLong count = (nameFormat != null) ? new AtomicLong(0) : null;
    return new ThreadFactory() {
      @Override public Thread newThread(Runnable runnable) {
        Thread thread = backingThreadFactory.newThread(runnable);
        if (nameFormat != null) {
          thread.setName(String.format(nameFormat, count.getAndIncrement()));
        }
        if (daemon != null) {
          thread.setDaemon(daemon);
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

    for (int i = 0; i < cfds.size() - 1; i++) {
      resultsList.add(null);
    }

    for (int i = 0; i < threadrows.size(); i++) {
      Thread t = tf.newThread(new DistanceMatrixCalculator(gamma,
          threadrows.get(i), cfds, resultsList));
      threads.add(t);
    }

    for (Thread t : threads) {
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

  synchronized void start(UncaughtExceptionHandler eh) {
    ThreadFactory flusherThreadFactory = Threads.newDaemonThreadFactory(
        server.getServerName().toShortString() + "-MemStoreFlusher", eh);
    for (int i = 0; i < flushHandlers.length; i++) {
      flushHandlers[i] = new FlushHandler("MemStoreFlusher." + i);
      flusherThreadFactory.newThread(flushHandlers[i]);
      flushHandlers[i].start();
    }
  }

  boolean isAlive() {
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

      final UncaughtExceptionHandler handler) {
    final ThreadFactory namedFactory = getNamedThreadFactory(prefix);
    return new ThreadFactory() {
      @Override
      public Thread newThread(Runnable r) {
        Thread t = namedFactory.newThread(r);
        if (handler != null) {
          t.setUncaughtExceptionHandler(handler);
        }
        if (!t.isDaemon()) {
          t.setDaemon(true);
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

  synchronized void start(UncaughtExceptionHandler eh) {
    ThreadFactory flusherThreadFactory = Threads.newDaemonThreadFactory(
        server.getServerName().toShortString() + "-MemStoreFlusher", eh);
    for (int i = 0; i < flushHandlers.length; i++) {
      flushHandlers[i] = new FlushHandler();
      flusherThreadFactory.newThread(flushHandlers[i]);
      flushHandlers[i].start();
    }
  }

  boolean isAlive() {
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

      final UncaughtExceptionHandler handler) {
    final ThreadFactory namedFactory = getNamedThreadFactory(prefix);
    return new ThreadFactory() {
      @Override
      public Thread newThread(Runnable r) {
        Thread t = namedFactory.newThread(r);
        if (handler != null) {
          t.setUncaughtExceptionHandler(handler);
        }
        if (!t.isDaemon()) {
          t.setDaemon(true);
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

  synchronized void start(UncaughtExceptionHandler eh) {
    ThreadFactory flusherThreadFactory = Threads.newDaemonThreadFactory(
        server.getServerName().toString() + "-MemStoreFlusher", eh);
    for (int i = 0; i < flushHandlers.length; i++) {
      flushHandlers[i] = new FlushHandler();
      flusherThreadFactory.newThread(flushHandlers[i]);
      flushHandlers[i].start();
    }
  }

  boolean isAlive() {
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

    assertFalse(thread.isDaemon());
  }

  public void testDaemon_true() {
    ThreadFactory factory = builder.setDaemon(true).build();
    Thread thread = factory.newThread(monitoredRunnable);
    assertTrue(thread.isDaemon());
  }

  public void testPriority_custom() {
    for (int i = Thread.MIN_PRIORITY; i <= Thread.MAX_PRIORITY; i++) {
View Full Code Here

Examples of java.util.concurrent.ThreadFactory.newThread()

  }

  public void testPriority_custom() {
    for (int i = Thread.MIN_PRIORITY; i <= Thread.MAX_PRIORITY; i++) {
      ThreadFactory factory = builder.setPriority(i).build();
      Thread thread = factory.newThread(monitoredRunnable);
      assertEquals(i, thread.getPriority());
    }
  }

  public void testPriority_tooLow() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.