public class DaemonDemo {
	public static void main(String[] argv) {
		Thread t = new Thread( new CounterThread(new Counter(Long.parseLong(argv[0]))),"Daemon");
		t.setDaemon(true);
		t.start();
		
		new Thread( new CounterThread(new Counter(Long.parseLong(argv[1]))),"Normal").start();
	} //main()
} //class DaemonDemo
	
class CounterThread implements Runnable {
	private Counter counter;
	private Counter max;
	
	public CounterThread(Counter max) {
		this.max = max;
		this.counter = new Counter();
	} //constructor
	
	public void run() {
		long start = System.currentTimeMillis();
		while (counter.get() < max.get()) {
			counter.increment();
			System.out.println(Thread.currentThread().getName()+"'s counter state: "+counter.get() );
		} //while
	} //run
} //class CounterThread	
			
class Counter {
	private long counter;
	
	public void increment() {
		++counter;
	} //incremenet
	
	public long get() {
		return counter;
	} //get()
		
	public Counter() {
		this(0);
	} //constructor
	
	public Counter(long init) {
		counter = init;
	} //constructor
} //class Counter	
