Esempio

public static final Boolean lock = Boolean.TRUE;

public static void main( String[] args ) {
Runnable runnable = new Runnable() {
public void run() {
synchronized ( lock ) {
while ( true ) {
System.out.println( "Hello World!" ); //$NON-NLS-1$
try { wait( 1000 ); } catch (InterruptedException e) {}
}
}
}
};
Thread thread = new Thread( runnable );
thread.start();
try { Thread.sleep( 3000 ); } catch (InterruptedException e) {}
thread.stop();
}

Soluzione
Il seguente codice è l'estratto della doc Java (copyright di Sun Microsystems)
Molti utilizzi di stop devono essere sostituiti da un codice che semplicemente modifica una variabile in modo da indicare che l'esecuzione del thread di destinazione deve terminare.
Il thread di destinazione deve controllare regolarmente tale variabile e restituire dal metodo run in maniera ordinata se la variabile indica che deve essere arrestata l'esecuzione. Se il thread di destinazione attende a lungo (su una variabile di condizione, ad esempio, per interrompere questo stato dovrà essere utilizzato il metodo interrupt.
Utilizzare il StopSafeRunnable fornito.

public static abstract class StopSafeRunnable implements Runnable {
public final void run() {
while ( !stopped ) {
doRun();
}
}
public void stop() {
stopped = true;
}
public boolean isStopped() {
return stopped;
}
protected abstract void doRun();

private boolean stopped = false;
}

public static void main(String[] args) {
StopSafeRunnable runnable = new StopSafeRunnable() {
public void doRun() {
System.out.println( "Hello World" ); //$NON-NLS-1$
try { Thread.sleep( 1000 ); } catch (InterruptedException e) {}
}
};
Thread thread = new Thread( runnable );
thread.start();
try { Thread.sleep( 3000 ); } catch (InterruptedException e) {}
runnable.stop();
}