Stop Thread right after one Minute
问题 I have a JButton to invoke my thread. But what I actually want to do is to stop the thread just after the one minute! My actionListener Method is: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { new Frame2().setVisible(true); Thread t=new Thread(new Frame2()); t.start(); } My thread to run for only one minute is as follow: public void run(){ int i; while(!Thread.currentThread().isInterrupted()){ for(i=0;i<=100;i++){ if(i==100){ Thread.currentThread().interrupt(); } try