Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Certification
»
Programmer Certification (OCPJP)
Why am I not getting main when getName() is applied to the main method?
Erandika Withanage
,
Greenhorn
Aug 19, 2012 09:02:39
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
I want to get the name of the
thread
running the main() method and my code is as follows.
public class Name1Thread { public static void main(String[] args) { System.out.println("The thread " + Thread.currentThread().getName() + " is now running."); } }
When execured, what I get is:
The thread RMI TCP Connection(1)-127.0.0.1 is now running
I don't get this. According to K&B the thread name should be 'main'? Is it a problem with my settings or
IDE
(DrJava)?
Ulf Dittmer
,
Rancher
Aug 19, 2012 09:11:33
(0 cow)
(0 skulls)
1
+Pie
Number of slices to send:
Send
I wouldn't call it a "problem" with your IDE, but it is a consequence of using one. Run the code from the command line to see the difference.
Erandika Withanage
,
Greenhorn
Aug 19, 2012 09:49:58
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Thank you:). It works perfectly now.
Just wondering about the underlying reason?
Seems there's no escaping the good ole' command line.
Post by:
autobot
knowledge is the difference between drudgery and strategic action -- tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 827 times.
Similar Threads
testing concurrency and sleeping threads
Thread getName( ) method
Concurency logic
Thread State
Thread and volatile
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:35:55
.