If a multi threaded Java program has started numerous number
of threads, at any point in time how to know which thread is
currently executing/running ?

Answers were Sorted based on User's Feedback



If a multi threaded Java program has started numerous number of threads, at any point in time how t..

Answer / namita kapoor

You can check by putting following code in your program

Thread t = Thread.currentThread();
System.out.println("Current Thread: "+t);

Is This Answer Correct ?    36 Yes 1 No

If a multi threaded Java program has started numerous number of threads, at any point in time how t..

Answer / ss

currentThread() method is static method, so don't need to
create the thread object to call the method..

Below is the correct way ..

Thread t=Thread.currentThread();
System.out.println(t.getName());

Is This Answer Correct ?    13 Yes 0 No

If a multi threaded Java program has started numerous number of threads, at any point in time how t..

Answer / srinivas

by using currentThread() Method ,we can find which thread
is runing

Is This Answer Correct ?    12 Yes 0 No

If a multi threaded Java program has started numerous number of threads, at any point in time how t..

Answer / ankush sharma

We can check the current Thread name as
Thread t= new Thread.currentThread();
System.out.println(t.getName());

Is This Answer Correct ?    11 Yes 0 No

If a multi threaded Java program has started numerous number of threads, at any point in time how t..

Answer / adminraj

Check executing/running current thread by

currentThread() [Method]

public static Thread currentThread()

Find the currently executing thread.

Returns:

the currently executing thread

Is This Answer Correct ?    9 Yes 0 No

If a multi threaded Java program has started numerous number of threads, at any point in time how t..

Answer / akj504

but if I want check/findout within my program itself
How do I do that ?

Is This Answer Correct ?    2 Yes 8 No

If a multi threaded Java program has started numerous number of threads, at any point in time how t..

Answer / chellammal

Using Java Debugger "jdb" one gets information about
which thread currently executing threads

Is This Answer Correct ?    3 Yes 14 No

Post New Answer

More Core Java Interview Questions

In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?

0 Answers  


What is numeric promotion?

1 Answers  


Can we have any other return type than void for main method?

0 Answers  


What does three dots mean in java?

0 Answers  


What must a class do to implement an interface in java programming?

0 Answers  






There are 2 different ways to create an object. a)By using keyword "new" b)By using Class.forName ("className").newInstance(); What is the difference between these 2 methods.

3 Answers  


What is meant by nested loop?

0 Answers  


What is empty list in java?

0 Answers  


why doesn't java run on all platforms?

0 Answers  


Can we declare a constructor as final?

0 Answers  


What are the library functions in java?

0 Answers  


Mention a package that is used for linked list class in java.

0 Answers  


Categories