class incrementThread4 implements Runnable 
{;
    public void run() 
    {
        while(true)
        {
            try { Thread.sleep(500); } catch ( InterruptedException e) { }
            synchronized(ex4.count) { ex4.count++; }
            System.out.println("Increment Thread: " + ex4.count);
        }
    }
}
class resetThread4 implements Runnable 
{
    public void run() 
    {
        while(true)
        {
            try { Thread.sleep(5 * 1000); } catch ( InterruptedException e) { }
            synchronized(ex4.count) { ex4.count = ex4.count/2; }
            System.out.println("    Reset Thread: " + ex4.count);
        }
    }
}

public class ex4 {
    static public Integer count = 0;
    public static void main(String[] args) 
    {
        Thread thread1 = new Thread(new incrementThread4(), "thread1");
        Thread thread2 = new Thread(new resetThread4(), "thread2");
        //Start the threads
        thread1.start();
        thread2.start();

        try { Thread.sleep(15 * 1000); } catch ( InterruptedException e) { }
        thread1.suspend();
        try { Thread.sleep(10 * 1000); } catch ( InterruptedException e) { }
        thread1.resume();

        // lets stop the threads
        try { Thread.sleep(10 * 1000); } catch ( InterruptedException e) { }
        thread1.stop();
        thread2.stop();
        //Start the threads
        // thread1.start();
        // thread2.start();
    }
}
