Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

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 =;
public interrupt(){
synchronized (this) {
CommandThread = null;
conn = null;


public void commandAction(Command c, Displayable d){
commandThread = new Thread(this);


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

Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!