Reentrant Monitor in JavaAccording to Sun Microsystems, Java monitors are reentrant means java thread can reuse the same monitor for different synchronized methods if method is called from the method. Advantage of Reentrant MonitorIt eliminates the possibility of single thread deadlocking Let's understand the java reentrant monitor by the example given below: In this class, m and n are the synchronized methods. The m() method internally calls the n() method. Now let's call the m() method on a thread. In the class given below, we are creating thread using annonymous class. Test it NowOutput: this is n() method this is m() method Next TopicJava io |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India