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

How to use
getId
method
in
java.lang.Thread

Best Java code snippets using java.lang.Thread.getId (Showing top 20 results out of 10,881)

origin: netty/netty

@Override
public long id() {
  return t.getId();
}
origin: org.apache.commons/commons-lang3

  @Override
  public boolean test(final Thread thread) {
    return thread != null && thread.getId() == threadId;
  }
}
origin: stackoverflow.com

 Thread t = Thread.currentThread();    
int id = t.getId();
origin: stackoverflow.com

 private class MyTask implements Runnable {
  public void run() {
    long threadId = Thread.currentThread().getId();
    logger.debug("Thread # " + threadId + " is doing this task");
  }
}
origin: jenkinsci/jenkins

@Override
public void uncaughtException(Thread t, Throwable ex) {
  // if this was an OutOfMemoryError then all bets about logging are off - but in the absence of anything else...
  LOGGER.log(Level.SEVERE,
        "A thread (" + t.getName() + '/' + t.getId()
               + ") died unexpectedly due to an uncaught exception, this may leave your Jenkins in a bad way and is usually indicative of a bug in the code.",
        ex);
}
origin: apache/rocketmq

  public void removeFromWaitingThreadTable() {
    long currentThreadId = Thread.currentThread().getId();
    synchronized (this) {
      this.waitingThreadTable.remove(currentThreadId);
    }
  }
}
origin: jenkinsci/jenkins

  public int compare(Thread a, Thread b) {
    int result = compare(a.getId(), b.getId());
    if (result == 0)
      result = a.getName().compareToIgnoreCase(b.getName());
    return result;
  }
}
origin: apache/kafka

/**
 * Acquire the light lock protecting this consumer from multi-threaded access. Instead of blocking
 * when the lock is not available, however, we just throw an exception (since multi-threaded usage is not
 * supported).
 * @throws ConcurrentModificationException if another thread already has the lock
 */
private void acquire() {
  long threadId = Thread.currentThread().getId();
  if (threadId != currentThread.get() && !currentThread.compareAndSet(NO_CURRENT_THREAD, threadId))
    throw new ConcurrentModificationException("KafkaConsumer is not safe for multi-threaded access");
  refcount.incrementAndGet();
}
origin: jenkinsci/jenkins

private ThreadSorterBase() {
  ThreadGroup tg = Thread.currentThread().getThreadGroup();
  while (tg.getParent() != null) tg = tg.getParent();
  Thread[] threads = new Thread[tg.activeCount()*2];
  int threadsLen = tg.enumerate(threads, true);
  for (int i = 0; i < threadsLen; i++) {
    ThreadGroup group = threads[i].getThreadGroup();
    map.put(threads[i].getId(), group != null ? group.getName() : null);
  }
}
origin: redisson/redisson

@Override
public RFuture<Void> unlockAsync() {
  long threadId = Thread.currentThread().getId();
  return unlockAsync(threadId);
}
origin: redisson/redisson

@Override
public RFuture<Void> lockAsync(long leaseTime, TimeUnit unit) {
  final long currentThreadId = Thread.currentThread().getId();
  return lockAsync(leaseTime, unit, currentThreadId);
}
origin: redisson/redisson

@Override
public RFuture<Void> unlockAsync() {
  long threadId = Thread.currentThread().getId();
  return unlockAsync(threadId);
}
origin: redisson/redisson

@Override
public RFuture<Boolean> tryLockAsync(long waitTime, long leaseTime, TimeUnit unit) {
  long currentThreadId = Thread.currentThread().getId();
  return tryLockAsync(waitTime, leaseTime, unit, currentThreadId);
}
origin: redisson/redisson

@Override
public RFuture<Void> lockAsync(long leaseTime, TimeUnit unit) {
  final long currentThreadId = Thread.currentThread().getId();
  return lockAsync(leaseTime, unit, currentThreadId);
}
origin: redisson/redisson

@Override
public RFuture<Boolean> tryLockAsync(long waitTime, long leaseTime, TimeUnit unit) {
  long currentThreadId = Thread.currentThread().getId();
  return tryLockAsync(waitTime, leaseTime, unit, currentThreadId);
}
origin: redisson/redisson

@Override
public boolean isHeldByCurrentThread() {
  return isHeldByThread(Thread.currentThread().getId());
}
origin: ReactiveX/RxJava

  @Override
  public void run() {
    if (running != null) {
      running.countDown();
    }
    for (int i = 0; i < numStringsToSend; i++) {
      observer.onNext(Thread.currentThread().getId() + "-" + i);
      if (latch != null) {
        latch.countDown();
      }
      produced.incrementAndGet();
    }
  }
}
origin: ReactiveX/RxJava

  @Override
  public void run() {
    if (running != null) {
      running.countDown();
    }
    for (int i = 0; i < numStringsToSend; i++) {
      subscriber.onNext(Thread.currentThread().getId() + "-" + i);
      if (latch != null) {
        latch.countDown();
      }
      produced.incrementAndGet();
    }
  }
}
origin: org.apache.commons/commons-lang3

@Test(expected=IllegalArgumentException.class)
public void testThreadGroupsByIdFail() throws InterruptedException {
  ThreadUtils.findThreadById(Thread.currentThread().getId(), (String) null);
}
origin: org.apache.commons/commons-lang3

@Test
public void testThreadsByIdWrongGroup() throws InterruptedException {
  final Thread t1 = new TestThread("thread1_XXOOLL__");
  final ThreadGroup tg = new ThreadGroup("tg__HHEE22");
  try {
    t1.start();
    assertNull(ThreadUtils.findThreadById(t1.getId(), tg));
  } finally {
    t1.interrupt();
    t1.join();
    tg.destroy();
  }
}
java.langThreadgetId

Javadoc

Returns the identifier of this Thread. The thread ID is a positive long number generated when this thread was created. The thread ID is unique and remains unchanged during its lifetime. When a thread is terminated, this thread ID may be reused.

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,
  • isInterrupted,
  • isAlive,
  • setPriority,
  • yield,
  • getThreadGroup,
  • getPriority

Popular in Java

  • Reactive rest calls using spring rest template
  • setScale (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • getSystemService (Context)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JComboBox (javax.swing)
  • Runner (org.openjdk.jmh.runner)
  • Top Vim plugins
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