|
Eu tenho a seguinte classe:
class Processo implements Runnable
{
private Thread thread; public boolean interrompido; public Processo( ThreadGroup tg, String id ) { this.interrompido = false; this.thread = new Thread( tg, this, id ); this.thread.setPriority( Thread.MIN_PRIORITY ); this.thread.start(); } public void run() { while( !interrompido ) { // Algo } } } que � inst�nciada sempre que o usu�rio clica no
bot�o Adicionar.
Para remover a thread estou usando esse
c�digo:
String id = this.jtfId.getText();
if ( ev.getSource() == this.jbRemover )
{
if ( !id.equals( "" ) ) { Thread[] processos = new Thread[ this.so.threadGroup.activeCount() ]; int threadCount = this.so.threadGroup.enumerate( processos ); boolean removeu = false; for ( int i = 0, l = processos.length; (i < l) && (!removeu); i++ ) { if ( processos[ i ].getName().equals( id ) ) { System.out.println( "Achei:" + id ); // * removeu = true; } } } }
* Nesse momento eu acho a thread e quero alterar o
valor da vari�vel interrompido da inst�ncia da classe Processo que foi
utilizada na cria��o dessa thread. Como eu obtenho essa refer�ncia?
Obrigado.
Abra�os,
Saulo Brito
|
