Performing multiple tasks by multiple threads (multitasking in multithreading)

If you have to perform multiple tasks by multiple threads,have multiple run() methods.For example:


\begin{lstlisting}
class Simple1 extends Thread{
public void run(){
System.o...
...mple2 t2=new Simple2();
\par
t1.start();
t2.start();
}
}
\end{lstlisting}
Output


\begin{lstlisting}
Output:task one
task two
\end{lstlisting}