import javax.swing.*; public class RunnableTwo implements Runnable { private Thread t = new Thread(this); private JTextArea textArea; private boolean alive; private boolean active; public RunnableTwo(JTextArea textArea) { this.textArea = textArea; active = true; alive = true; t.start(); } public void kill(){ active = false; alive = false; } public void pause(){ active = false; } public void restart(){ active = true; } public void run() { while(alive){ while(active){ textArea.append("Thread 2\n"); textArea.setCaretPosition(textArea.getText().length()); try { t.sleep(1000); } catch(InterruptedException ie) {} } } } }