Posts

Showing posts with the label thread

Thread in Android

Thread A thread is the unit of execution within a process. Java provides two ways to create a thread programmatically. Way 1) Extending the java.lang.Thread class.    new ExampleThread().start();     //Step 1 - Extend the Thread base class     class ExampleThread extends Thread{         @Override         public void run() {             for (int i = 0; i < 10; i++) {                 try {                     Thread.sleep(1000);                 } catch (InterruptedException e) {                     e.printStackTrace();                 }         }     } Way 2) Implementing the java.lang.Runnable interface. ...