Tabnine Logo
Thread.isDaemon
Code IndexAdd Tabnine to your IDE (free)

How to use
isDaemon
method
in
java.lang.Thread

Best Java code snippets using java.lang.Thread.isDaemon (Showing top 20 results out of 3,753)

origin: netty/netty

@Override
public boolean isDaemon() {
  return t.isDaemon();
}
origin: redisson/redisson

@Override
public boolean isDaemon() {
  return t.isDaemon();
}
origin: ctripcorp/apollo

 @Override
 public boolean satisfy(Thread thread) {
  return !thread.isAlive() || thread.isInterrupted() || thread.isDaemon();
 }
});
origin: nostra13/Android-Universal-Image-Loader

  @Override
  public Thread newThread(Runnable r) {
    Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
    if (t.isDaemon()) t.setDaemon(false);
    t.setPriority(threadPriority);
    return t;
  }
}
origin: apache/zookeeper

  public Thread newThread(Runnable r) {
    Thread t = new Thread(group, r,
               namePrefix + threadNumber.getAndIncrement(),
               0);
    if (!t.isDaemon())
      t.setDaemon(true);
    if (t.getPriority() != Thread.NORM_PRIORITY)
      t.setPriority(Thread.NORM_PRIORITY);
    return t;
  }
}
origin: lingochamp/FileDownloader

  @Override
  public Thread newThread(Runnable r) {
    Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
    if (t.isDaemon()) t.setDaemon(false);
    if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY);
    return t;
  }
}
origin: apache/storm

  @Override
  public Thread newThread(Runnable r) {
    Thread t = new Thread(group, r, name + "-" + index.getAndIncrement(), 0);
    if (t.isDaemon()) {
      t.setDaemon(false);
    }
    if (t.getPriority() != Thread.NORM_PRIORITY) {
      t.setPriority(Thread.NORM_PRIORITY);
    }
    t.setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER);
    return t;
  }
}
origin: alibaba/jstorm

  public Thread newThread(Runnable runnable) {
    Thread t = new Thread(group, runnable, name + "-" + index.getAndIncrement(), 0);
    if (t.isDaemon())
      t.setDaemon(false);
    if (t.getPriority() != Thread.NORM_PRIORITY)
      t.setPriority(Thread.NORM_PRIORITY);
    return t;
  }
}
origin: apache/hbase

 @Override
 public Thread newThread(Runnable r) {
  Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
  if (!t.isDaemon()) {
   t.setDaemon(true);
  }
  if (t.getPriority() != Thread.NORM_PRIORITY) {
   t.setPriority(Thread.NORM_PRIORITY);
  }
  return t;
 }
}
origin: netty/netty

@Override
public Thread newThread(Runnable r) {
  Thread t = newThread(FastThreadLocalRunnable.wrap(r), prefix + nextId.incrementAndGet());
  try {
    if (t.isDaemon() != daemon) {
      t.setDaemon(daemon);
    }
    if (t.getPriority() != priority) {
      t.setPriority(priority);
    }
  } catch (Exception ignored) {
    // Doesn't matter even if failed to set.
  }
  return t;
}
origin: redisson/redisson

@Override
public Thread newThread(Runnable r) {
  Thread t = newThread(FastThreadLocalRunnable.wrap(r), prefix + nextId.incrementAndGet());
  try {
    if (t.isDaemon() != daemon) {
      t.setDaemon(daemon);
    }
    if (t.getPriority() != priority) {
      t.setPriority(priority);
    }
  } catch (Exception ignored) {
    // Doesn't matter even if failed to set.
  }
  return t;
}
origin: google/guava

public void testDaemon_false() {
 ThreadFactory factory = builder.setDaemon(false).build();
 Thread thread = factory.newThread(monitoredRunnable);
 assertFalse(thread.isDaemon());
}
origin: google/guava

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

private static boolean isDaemon(String name) {
 Thread t = getThread(name);
 return (t != null) && t.isDaemon();
}
origin: google/guava

public void testGetExitingExecutorService_executorSetToUseDaemonThreads() {
 TestApplication application = new TestApplication();
 ThreadPoolExecutor executor =
   new ThreadPoolExecutor(1, 2, 3, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
 assertNotNull(application.getExitingExecutorService(executor));
 assertTrue(executor.getThreadFactory().newThread(EMPTY_RUNNABLE).isDaemon());
}
origin: google/guava

public void testThreadFactoryBuilder_defaults() throws InterruptedException {
 ThreadFactory threadFactory = builder.build();
 Thread thread = threadFactory.newThread(monitoredRunnable);
 checkThreadPoolName(thread, 1);
 Thread defaultThread = Executors.defaultThreadFactory().newThread(monitoredRunnable);
 assertEquals(defaultThread.isDaemon(), thread.isDaemon());
 assertEquals(defaultThread.getPriority(), thread.getPriority());
 assertSame(defaultThread.getThreadGroup(), thread.getThreadGroup());
 assertSame(defaultThread.getUncaughtExceptionHandler(), thread.getUncaughtExceptionHandler());
 assertFalse(completed);
 thread.start();
 thread.join();
 assertTrue(completed);
 // Creating a new thread from the same ThreadFactory will have the same
 // pool ID but a thread ID of 2.
 Thread thread2 = threadFactory.newThread(monitoredRunnable);
 checkThreadPoolName(thread2, 2);
 assertEquals(
   thread.getName().substring(0, thread.getName().lastIndexOf('-')),
   thread2.getName().substring(0, thread.getName().lastIndexOf('-')));
 // Building again should give us a different pool ID.
 ThreadFactory threadFactory2 = builder.build();
 Thread thread3 = threadFactory2.newThread(monitoredRunnable);
 checkThreadPoolName(thread3, 1);
 assertThat(thread2.getName().substring(0, thread.getName().lastIndexOf('-')))
   .isNotEqualTo(thread3.getName().substring(0, thread.getName().lastIndexOf('-')));
}
origin: google/guava

public void testGetExitingScheduledExecutorService_executorSetToUseDaemonThreads() {
 TestApplication application = new TestApplication();
 ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
 assertNotNull(application.getExitingScheduledExecutorService(executor));
 assertTrue(executor.getThreadFactory().newThread(EMPTY_RUNNABLE).isDaemon());
}
origin: org.apache.commons/commons-lang3

/**
 * Helper method for testing whether the daemon flag is taken into account.
 *
 * @param flag the value of the flag
 */
private void checkDaemonFlag(final boolean flag) {
  final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
  final Runnable r = EasyMock.createMock(Runnable.class);
  final Thread t = new Thread();
  EasyMock.expect(wrapped.newThread(r)).andReturn(t);
  EasyMock.replay(wrapped, r);
  final BasicThreadFactory factory = builder.wrappedFactory(wrapped).daemon(
      flag).build();
  assertSame("Wrong thread", t, factory.newThread(r));
  assertTrue("Wrong daemon flag", flag == t.isDaemon());
  EasyMock.verify(wrapped, r);
}
origin: google/guava

public void testThreadFactory() throws InterruptedException {
 final String THREAD_NAME = "ludicrous speed";
 final int THREAD_PRIORITY = 1;
 final boolean THREAD_DAEMON = false;
 ThreadFactory backingThreadFactory =
   new ThreadFactory() {
    @Override
    public Thread newThread(Runnable r) {
     Thread thread = new Thread(r);
     thread.setName(THREAD_NAME);
     thread.setPriority(THREAD_PRIORITY);
     thread.setDaemon(THREAD_DAEMON);
     thread.setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER);
     return thread;
    }
   };
 Thread thread =
   builder.setThreadFactory(backingThreadFactory).build().newThread(monitoredRunnable);
 assertEquals(THREAD_NAME, thread.getName());
 assertEquals(THREAD_PRIORITY, thread.getPriority());
 assertEquals(THREAD_DAEMON, thread.isDaemon());
 assertSame(UNCAUGHT_EXCEPTION_HANDLER, thread.getUncaughtExceptionHandler());
 assertSame(Thread.State.NEW, thread.getState());
 assertFalse(completed);
 thread.start();
 thread.join();
 assertTrue(completed);
}
origin: ReactiveX/RxJava

  @Test
  public void normal() {
    RxThreadFactory tf = new RxThreadFactory("Test", 1);

    assertEquals("RxThreadFactory[Test]", tf.toString());

    Thread t = tf.newThread(Functions.EMPTY_RUNNABLE);

    assertTrue(t.isDaemon());
    assertEquals(1, t.getPriority());
  }
}
java.langThreadisDaemon

Javadoc

Tests if this thread is a daemon thread.

Popular methods of Thread

  • currentThread
  • sleep
    Causes the currently executing thread to sleep (temporarily cease execution) for the specified numbe
  • <init>
    Constructs a new Thread with no Runnable object, the given name and belonging to the ThreadGroup pas
  • start
    Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread
  • getContextClassLoader
    Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator
  • interrupt
    Interrupts this thread. Unless the current thread is interrupting itself, which is always permitted,
  • setDaemon
    Marks this thread as either a #isDaemon thread or a user thread. The Java Virtual Machine exits when
  • getName
    Returns this thread's name.
  • join
    Waits at most millis milliseconds plus nanos nanoseconds for this thread to die. This implementatio
  • setContextClassLoader
    Sets the context ClassLoader for this Thread. The context ClassLoader can be set when a thread is cr
  • setName
    Changes the name of this thread to be equal to the argumentname. First the checkAccess method of thi
  • interrupted
    Tests whether the current thread has been interrupted. Theinterrupted status of the thread is cleare
  • setName,
  • interrupted,
  • getStackTrace,
  • getId,
  • isInterrupted,
  • isAlive,
  • setPriority,
  • yield,
  • getThreadGroup,
  • getPriority

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • findViewById (Activity)
  • runOnUiThread (Activity)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now