0

example of thread and use !!

13th Sep 2016, 6:30 PM
Bhushan Gaikwad
Bhushan Gaikwad - avatar
5 Respuestas
0
Threads are implemented in the form of objects that contain a method called run(). The run() method is the heart and soul of any thread. public void run() { /* Your implementation of thethread here*/ }
13th Sep 2016, 6:33 PM
sabreen anjum
sabreen anjum - avatar
0
if i write run() methods then it automatically becomes thread ?. i dnt understand .. explain plz !!
13th Sep 2016, 6:36 PM
Bhushan Gaikwad
Bhushan Gaikwad - avatar
0
or simply give an example
13th Sep 2016, 6:37 PM
Bhushan Gaikwad
Bhushan Gaikwad - avatar
0
The run() method should be invoked by an object of the concerned thread.This can be achieved by creating the thread and initiating it with the help of another thread method called start(). A new thread can be created in two ways: 1. By creating a thread class: Define a class that extends Thread class and override its run() method with the code required by the thread. 2. By converting a class to a thread: Define a class that implements Runnable interface.The runnable interface has only one method, run(), that is to be defined in the method with the code to be executed by the thread.
13th Sep 2016, 6:42 PM
sabreen anjum
sabreen anjum - avatar
0
thnx bro :-)
13th Sep 2016, 7:50 PM
Bhushan Gaikwad
Bhushan Gaikwad - avatar