Every Object has a monitor , acquiring that monitors allow thread to hold lock on object. But Thread class does not have any monitors. When notify method is called on object by thread it notifies all the threads which are waiting for that object monitor that object monitor is available now. This is funny June 1, at PM. Newer Post Older Post Home.
Subscribe to: Post Comments Atom. Subscribe for Discounts and Updates Follow. Search This Blog. Interview Questions core java interview question data structure and algorithm 78 Coding Interview Question 75 interview questions 70 design patterns 35 SQL Interview Questions 34 object oriented programming 34 thread interview questions 30 spring interview questions 28 collections interview questions 25 database interview questions 16 servlet interview questions 15 Programming interview question 6 hibernate interview questions 6.
How to design a vending machine in Java? How HashMap works in Java? Why String is Immutable in Java? Translate This Blog. ClassNotFoundException: org. Law of Demeter in Java - Principle of least Knowle When to Make a Method Static in Java? Is it possible to have an abstract method in a fin Top 5 Courses to learn Groovy and Grails in Why Enum Singleton are better in Java? Difference between repaint and revalidate method i How to Count number of Set bits or 1's of Integer When a class is loaded and initialized in JVM - Ja Is Swing Thread Safe in Java?
How to get current URL, parameters and Hash tag us How ClassLoader Works in Java? Example 3 ways to solve java. NoClassDefFoundError in How to use Comparator and Comparable in Java? How to compare two lists of values in Microsoft Ex How to increase Heap memory of Apache Tomcat Serve What is bounded and unbounded wildcards in Generic How to Split String based on delimiter in Java? Difference between Right shift and Unsigned right What is the maximum Heap Size of 32 bit or bit How to set in Eclipse I How to add and substract days in current date in J Java Program to find factorial of number in Java Difference between Stub and Mock object in Java Un How to Compare Two Enum in Java?
Difference Between Abstract Class vs Interface in What is String args[] Argument in Java Main metho Because if these methods were to be defined in thread class then the in public class of the application containing the main method could not call these methods. For example, think of a multi-threaded application that has processing queues, each queue has a Thread to take messages out of the queue and process them. The focus here is whether the Queue has messages to process, not whether the Thread should wake up and resume its work.
With a Queue object, the Runnable task your code could put the Queue on hold, by using its wait method, until such time as a message would be sent to the Queue and the Queue could call its own notify method to signal your code that processing of the new message should start. This would be bending ideal concepts of OOP where the Queue alone should be responsible for knowing when a message was just posted to it!
When ever we are calling this method form a object only. When a object comes to mind in java than it must inherit the Object class. There is provision for creating classes without extending java. Thread class, ie by Implementation of java. Runnable interface. If the thread is created through this process we, to avail the concerned methods to it, which indeed possible through direct or indirect inheritance from java.
When you use threads in Java and there are synchronized blocks methods or code blocks declared with the synchronized key word you need a monitor for the thread to lock on. This monitor can be any Java object.
No Account? Sign up. Executorservice Tutorial. Serialization And Deserialization Java Example. Convert Hashmap To List Java. Hello World Java Program Breakup. Join our subscribers list to get the latest updates and articles delivered directly in your inbox. Further Reading on Core Java 1.
0コメント