Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me to implement a function "Cancel" to terminate a Thread  RSS feed

 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I developped a application en MIDP1.0/CLDC 1.0.
I need to implement a function "Cancel" to interrupt a thread.
It aim to interrupt a connection.

Here my code:

Connection implements Runnable, CommandListener{
private CommandThread ;
public void run(){
//conn = httpConnection.open(MyURL);
}
public interrupt(){
synchronized (this) {
CommandThread = null;
conn = null;
System.gc();
}

}

public void commandAction(Command c, Displayable d){
if(c==downloadCommand){
commandThread = new Thread(this);
commandThread.start();
}
}

}



But it doesn't work. But in CLDC1.1 there is soution to interrupt a thread.

OULD NADIF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!