Results 1 to 1 of 1
Thread: How to get thread name
-
How to get thread name
This Java tip shows how to get the name of a thread.
Java Code:public class TwoThreadGetName extends Thread { public void run() { for (int i = 0; i < 10; i++) { printMsg(); } } public void printMsg() { Thread t = Thread.currentThread(); String name = t.getName(); System.out.println("name=" + name); } public static void main(String[] args) { TwoThreadGetName tt = new TwoThreadGetName(); tt.start(); for (int i = 0; i < 10; i++) { tt.printMsg(); } } }
Similar Threads
-
data from the main/GUI thread to another runnin thread...
By cornercuttin in forum Threads and SynchronizationReplies: 2Last Post: 04-23-2008, 10:30 PM -
If JNI thread call the java object in another thread, it will crash.
By skaterxu in forum Advanced JavaReplies: 0Last Post: 01-28-2008, 07:02 AM -
using Thread
By one198 in forum New To JavaReplies: 1Last Post: 11-21-2007, 08:01 AM -
How come multi thread don't look like it?
By jkhoa in forum Threads and SynchronizationReplies: 1Last Post: 09-22-2007, 04:25 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks