Jump to content
  • Advertisement


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


How to kill the thread?

This topic is 5319 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 gamedev.net 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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!