Wednesday, June 14, 2006

Daemon Thread

Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system.

"setDaemon" method is used to create a daemon thread.

Thursday, June 01, 2006

Runnable Interface

class MyRunnable implements Runnable
{
public void run()
{
System.out.println("Inside run()");
}
}


Next, create an instance of the class and construct a thread, passing the instance of the class as an argument to the constructor:

MyRunnable mc = new MyRunnable();
Thread t = new Thread(mc);


To start the thread, use the start() method as shown here:
t.start();