Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Getting Current Thread Name in Java

  1. public class GetThreadName {
  2. public static void main(String[] args) {
  3. /*
  4. * To get the reference of currently running thread, use
  5. * Thread currentThread() method of Thread class.
  6. *
  7. * This is a static method.
  8. */
  9. Thread currentThread = Thread.currentThread();
  10. System.out.println(currentThread);
  11. }
  12. }