Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6583731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:26:50+00:00 2026-05-25T16:26:50+00:00

A thread: public class DrawThread extends Thread { private RMapCanvas canvas; final Handler myHandler

  • 0

A thread:

    public class DrawThread extends Thread {
    private RMapCanvas canvas;
    final Handler myHandler = new Handler();
    final ArrayList<RGroupMapLayer> layers;

    public DrawThread(RMapCanvas aCanvas, ArrayList<RGroupMapLayer> arrayOfLayers)
    {
        canvas = aCanvas;
        layers = arrayOfLayers;
    }

    public void run() {
        activity.RaiseNotification(activity.getApplicationContext().getResources().getString(R.string.loading).toString());
        for (RGroupMapLayer l : layers)
             {
                 l.validateAndRepairView(false, canvas.renderer, canvas.mapView);
                 l.render(canvas.renderer, canvas.mapView, canvas.mapEvent, 5000000, 5000000);
                 if (settings.getPositionFeature() != null)
                 {
                     RPointFeatureStyle positionStyle = new RPointFeatureStyle(RPointFeatureStyle.SIMPLE_POINT_STYLE_GPS);
                     positionStyle.render(settings.getPositionFeature(), renderer, mapView);
                 }
                 myHandler.post(new Runnable() {
                     @Override
                     public void run() {
                         canvas.RenderComplete(); 
                     }});
             }
     activity.statusMessage.cancel();
    }

    public synchronized void requestStop() {
        activity.statusMessage.cancel();
        this.interrupt();
    }
}

Calling the requestStop that interrupts a thread is not enough. The thread just keeps running. Can some one please update the code to show me the correct way of stopping this thread? And by the way … the RenderComplete() methods updates the UI (witch is a problem in my case, because “old” threads keep updating the UI even if new one is starter and the old one interrupted).

Thanx in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:26:51+00:00Added an answer on May 25, 2026 at 4:26 pm

    In general interrupting or stoping threads by yourself is not recommended. Your thread should have a flag inside the run method. When the flag is true – the thread is running, when the flag is false – thread is also running, but now it doesn’t do anything. The system will stop this thread when needed. Here’s how it should look:

        public void run() {
            while (flag) {
            //do your work
            }
        }
    

    And to “stop” the thread just use flag = false;

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class PlayText extends Thread { private int duration; private String text; private PlayerScreen
public class Test extends Thread{ public void hello(String s){ System.out.println(s); } public void run(){
In other words, is this Singleton implementation thread safe: public class Singleton { private
Please look at my code.. public class BseDemo extends Activity { final String feedUrlString
public class fraktal extends JFrame { public fraktal (String args[]) { calc = new
i have executed the following code public class Activity_Threads_Handler extends Activity { private int
public class MainClass { private static final int size = 5; private ExecutorService prodExec
Folks, Here is a simplified code for my background thread: public class MyThread extends
Say I've got something like this public void run(){ Thread behaviourThread = new Thread(abstractBehaviours[i]);
Is this thread safe? private static bool close_thread_running = false; public static void StartBrowserCleaning()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.