Simple Multithread program

Submitted by Karthik on

import java.io.*;
class patient implements Runnable
{
    Thread t;
    String n;
    patient(String name)
    {
        n = name;
        t = new Thread(this);
        t.setName(name);
        t.start();
    }
    synchronized void attend()
    {
        try
        {
            System.out.println("Doctor is diagnosing the patient :" +n);
            Thread.sleep(1500);
        }
        catch(InterruptedException e)
        {
            System.out.println("Extension interrupted");
        }

    }
    public void run()
    {
        attend();
    }
}
class muldemo
{
    public static void main(String args[]) throws IOException
    {
        patient in[] = new patient[10];
        int count = 0;
        int w = 0;
        System.out.println("Hospital Simulation");
        try
        {
            do
            {
                String name = getstring();
                System.out.println("Name of the patient:"+name);
                System.out.println("Waiting time in mins :" +w);
                in[count] = new patient(name);
                Thread.sleep(2000);
                System.out.println("Two mins rest for doctor");
                        w+=12;
                        count++;
            }
            while(count<5);
        }
        catch(InterruptedException e)
        {
            System.out.println("Exception Interrupted");
        }
    }
    public static String getstring() throws IOException
    {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String s = br.readLine();
        return(s);
    }
}