class incrementThread implements Runnable {
    Thread runner;
    public incrementThread() { }
    public incrementThread(String threadName) {
        runner = new Thread(this, threadName); 
        runner.start(); 
    }
    public void run() {
        while(true)
        {
            try { Thread.sleep(1 * 1000); } catch ( InterruptedException e) { }
            ex3.count++;
            System.out.println("Increment Thread: " + ex3.count);
        }
    }
}
class resetThread implements Runnable {
    Thread runner;
    public resetThread() { }
    public resetThread(String threadName) {
        runner = new Thread(this, threadName); 
        runner.start(); 
    }
    public void run() {
        while(true)
        {
            try { Thread.sleep(5 * 1000); } catch ( InterruptedException e) { }
            ex3.count = ex3.count/2;
            System.out.println("    Reset Thread: " + ex3.count);
        }
    }
}

public class ex3 {
    static int count = 0;
    public static void main(String[] args) 
    {
        Thread thread1 = new Thread(new incrementThread(), "thread1");
        Thread thread2 = new Thread(new resetThread(), "thread2");
        //Start the threads
        thread1.start();
        thread2.start();
        try { Thread.sleep(12 * 1000); } catch ( InterruptedException e) { }
        System.out.println("Parent Thread - Killing Thread 2 ");
        thread2.stop();
    }
}
