public class c_easter_proxy extends JFrame implements ActionListener,Runnable { public String q = ""; //THREAD RNNING public void run() { while(q == "") { try { Thread.sleep(2000); System.out.println("yo"); } catch(InterruptedException i) { ta1.append("\nsystem error: "+i); } } } // THREAD STARTING private void alusta_proxi_thread() throws java.lang.InterruptedException { Runnable ot = new c_easter_proxy(); Thread th = new Thread(ot); th.start(); } // ACTION PERFORM public void actionPerformed(ActionEvent e) { JButton o = (JButton)e.getSource(); if(o.getText() == "Alusta PROXY_OTSINGUT") { try { alusta_proxi_thread(); b1.setEnabled(false); b2.setEnabled(true); ta1.append("\nproxy otsing käib.."); } catch(InterruptedException i) { ta1.append("\nsystem error: "+i); } } else if(o.getText() == "Lõpeta PROXY_OTSING") { b1.setEnabled(true); b2.setEnabled(false); q = "1"; // Changing value of q ta1.append("\nproxy otsing lõpetatud."); } } // End of actionPerformed