Extending the Thread class:
Thread T = new NewThread();
T.start();
private class NewThread extends Thread {
@Override
public void run() {
//Your asynchronous code
}
}
Implementing the Runnable interface:Thread T = new Thread(new NewRunnable());
T.start();
private class NewRunnable implements Runnable {
public void run() {
//Your asynchronous code
}
}
Your activity may implement the Runnable interface directly.In this case, when creating the Thread object you must pass the activity (this) as the parameter.
No comments:
Post a Comment