Advertisement Jump to content


This topic is now archived and is closed to further replies.


How to kill the thread?

This topic is 5411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am having a little weird problem! I am following the tutorial of MIDP 1.0 found here in The problem is.. how can i exit the program? returning from run() simply doesn''t make the program close! What is the way to exit the program? Thank you very much in advance...

Share this post

Link to post
Share on other sites
Calling notifyDestroyed() should do it.

You may want to implement destroyApp() in such a way that it kills your thread. One way to do this:

public class myTest extends Midlet implements Runnable {

private boolean running;
private Thread t;
public void startApp() {
running = true;
t = new Thread(this);
t.start(); // hold on to a reference


public void run() {
while(running) {
// do something


public void destroyApp() {
running = false; // allow thread to break out of loop

t.join(); // wait until that thread finishes its last iteration

// any other cleanup here


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!