• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wait method (multithreading) currentmethod

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen the wait method being called without any reference.
Even if its static (in case it is; i dont know) should you not write the class name.

Also what exactly is the currentMethod() method and when did it replace new class_name()???
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to check the API to find out whether it is static.

Remember what a call to a method without a . before it means, and (assuming it is an instance method) which object that is called on.
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh . . . I hadn't finished my post yet.

Where is currentMethod() from? I have never heard of it.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:
Where is currentMethod() from? I have never heard of it.



Maybe the question was about the currentThread() method, which is a static method of the Thread class, that returns the Thread object of the calling thread.

Henry
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sounds likely, Henry. Thank you.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Campbell Ritchie wrote:
Where is currentMethod() from? I have never heard of it.



Maybe the question was about the currentThread() method, which is a static method of the Thread class, that returns the Thread object of the calling thread.

Henry



Perhaps, but Varun, can you be more specific? Even assuming you mean Thread.currentThread(), then the following statement doesn't make sense:

Also what exactly is the Thread.currentThread() method and when did it replace new class_name()?


Can you tell us what you mean and why you think that method (currentThread() or currentMethod()) replaced creating a new object?
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Current Thread is a static method in Thread class. It returns the Thread name,priority (by default 5 i.e NORM_PRIORITY) and method name in which it was invoked.

i.e if you call method currentThread in run mthod of Thread and then start thread from the main method, answer would be like
Thread[Thread-0,5,main].

And about wait() method is not the static method.It is instance method in Object class. That is super daddy of all classes that you write in Java
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anil Deshpande wrote:Current Thread is a static method in Thread class. It returns the Thread name,priority (by default 5 i.e NORM_PRIORITY) and method name in which it was invoked.



Not true. It returns a reference to the currently running Thread. See the API: java.lang.Thread.

i.e if you call method currentThread in run mthod of Thread and then start thread from the main method, answer would be like
Thread[Thread-0,5,main].



Which is the output for Thread#toString(). So this output is only returned when you call Thread.currentThread().toString() (or send the thread reference to some other method which does the toString() part, for example by calling System.out.println(Thread.currentThread()))
 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, That os more precise answer
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic