Thursday 9 February 2017

Java Tutorial Java Thread (Reentrant monitor | Reentrant lock in java)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=Z6yStBsCzvw&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial Java Thread (Reentrant monitor | Reentrant lock in java)
DisplayMessage.java
class DisplayMessage
{
    /*
     * Declaring two synchronized method displayName() and
     * displayHello().one synchronized method calling to
     * another one.
     */
    public synchronized void displayName()
    {
        displayHello();
        System.out.println("Peter");
    }

    public synchronized void displayHello()
    {
        System.out.print("Hello ");
    }
}
ReentrantExample.java
public class ReentrantExample
{
    public static void main(String args[])
    {
        Thread t1 = new Thread()
        {
            public void run()
            {
                new DisplayMessage().displayName();
            }
        };
        t1.start();
    }
}
Output
Hello Peter

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/Thread_ReentrantDemo_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/Thread_ReentrantDemo_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/644abf74fceeb240066dd3d2fe2e4b1fb6c4bd48/BasicJava/Thread_ReentrantDemo_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment