how do you create thread?

how do you create thread?

Postby Kishan » Fri Feb 01, 2013 5:28 am

how do you create thread?
Kishan
 
Posts: 191
Joined: Tue Jan 29, 2013 4:21 am

Re: how do you create thread?

Postby javalatte » Tue Feb 05, 2013 12:34 am

You have to extend the Thread class or implement the Runnabe interface and override/implement the run() method.
//extend Thread----1
class MyClass extends Thread{
public void run() {//give implementation}
...
}
//implement Runnable----2
class MyClass implements Runnable{
public void run() {//give implementation}
...
}
//do 1 or 2, then follows
Thread t1 = new Thread(new MyClass());
t1.start();
javalatte
 
Posts: 55
Joined: Tue Jan 29, 2013 2:31 pm


Return to Core Java

Who is online

Users browsing this forum: No registered users and 1 guest

cron