creating multiple threads ?
creating multiple threads ?
I have implemented a Thread in my java program, by implementing Runnable interface.
& i wrote the desired content in the run().
Like this;
class Test1extends JFrameimplements Runnable,ActionListener{
public Test1(){
.....
Thread t1 =new Thread(this);
t1.start();
.....
...
}
publicvoid run(){
while(true){
..........
.......//do the tasks
....
}
}
publicvoid actionPerformed(ActionEvent e){
Object source = e.getSource();
if(source==btn1){
//task1
//subtask1.1
//subtask1.2
}elseif(source==btn2){
//task2
//subtask2.1
//subtask2.2
}
}
publicstaticvoid main(String args[]){
Test1 tst =new Test1();
}
}
Problem is how can I assign actionPerformed method to another thread.
(So that, subtask1.1 & 1.2 running on different threads)
Things in actionPerformed method should run in another thread
Can i have another new Thread (say t2) below the thread t1. (t1 above created)
Thread t2 =new Thread();
if so, what should be put inside the().
(Earlier i putthis
. )
pls help

