The Java language support thread synchronization through the use of monitors. A monitor is associated with a specific data item and functions as a lock on that data. When a thread holds the monitor for some data item, other threads are locked out and cannot inspect or modify the data. In order to monitor a thread’s status Java have predefined currentThread.getName() method that is extended by Thread Class.The getName() method of java.lang.reflect.Method class is used to get the name of the entity, as a String, that entity can be class, interface, array, enum, method, etc. of the class object. The getName() method of java.lang.reflect. Method class is helpful to get the name of methods, as a String. To get name of all methods of a class, get all the methods of that class object. Then call getName() on those method objects.
public String getName()
Return Value: It returns the name of the method, as String.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.