Preview:
public class PrintMessage {
    synchronized void print(String Msg){
        System.out.println("["+Msg+"]");
    }
}



public class MessageSend {
    public static Runnable getSender(PrintMessage p,String Msg){
        return new Runnable() {
            private PrintMessage pMsg=p;
            private String Message=Msg;
            public void run(){
                pMsg.print(Message);
            }
        };
    }
}



public class MessageMain {
    public static void main(String[] args) {
        PrintMessage pMsg=new PrintMessage();
        String n1="CVR",n2="College",n3="Engineering";
        Runnable r1=MessageSend.getSender(pMsg,n1);
        Runnable r2=MessageSend.getSender(pMsg,n3);
        Runnable r3=MessageSend.getSender(pMsg,n2);

        new Thread(r1).start();
        new Thread(r2).start();
        new Thread(r3).start();
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter