I got an answer from my last question. But now I am unable to use and stop the Thread just after one minute after doing my things. I actually want to close/stop the thread after one minute after doing my things. So, I'm badly confused: how can I do this using:
public class Frame2 extends javax.swing.JFrame implements Runnable{
public Frame2() {
initComponents();
}
public void run(){
long startTime = System.currentTimeMillis();
while (( System.currentTimeMillis() - startTime ) < 1000) {
System.out.print("DOING MY THINGS");
}
}
}
The problem is that it is not working at all and when I close the frame containing this Thread the line of code
System.out.print("DOING MY THINGS");
works in an infinite loop.
Thanks in advance.