CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2011
    Posts
    2

    forcefully stop a thread

    Hi all,

    I have a thread in J2ME which calls another application. My requirement is to forcefully stop the thread after some fixed interval..

    Anyboday please help me to close the thread forcefully as the particular application can not be closed by itself and no code can be added in that application as it is system defined..

    Thanks

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: forcefully stop a thread

    Can you clarify some points:

    1. Are you saying you can't close the application called by the thread?
    2. Is the application called by the thread an external executable?
    3. Can you add code to the thread that calls the application?
    4. How is the application called by the thread?

    Precise language is not the problem. Clear language is the problem...
    R. Feynman
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Mar 2011
    Posts
    2

    Re: forcefully stop a thread

    Thanks for the reply..

    To give a brief summary about my task before answering the questions..

    I am working on blackberry application development and my application calls the in built blackberry Map to show the particular location i want to display (Which i have succeeded) but the location keeps changing and I want to update the same on the map.. For this I dont want the user to forcefully close the application to show the update..

    To answer ur questions..
    1. I can close the application manually but I dont want that to be done.
    2. Yes.. The thread calls an external application.
    3. Yes.. I am able to add the code and call the application.
    4. The application is called by blackberry api Invoke.

    Some code snippet for your reference

    public class UpateThread extends Thread{
    BM_SingleLoc singleLocScreen;
    public UpateThread(BM_SingleLoc singleLocScreen){
    this.singleLocScreen = singleLocScreen;
    }

    public void run(){
    //for(;{
    try{
    Thread.sleep(10000);
    }catch(InterruptedException e){
    // Catch the exception here
    }
    UiApplication.getUiApplication().invokeLater(new Runnable() {

    public void run() {
    // TODO Auto-generated method stub
    singleLocScreen.callMap();
    }
    });
    //}
    }
    }


    ---------------------

    public final class BM_SingleLoc extends MainScreen
    {
    public BM_SingleLoc()
    {
    UpateThread thread = new UpateThread(this);
    thread.start();

    }

    public void callMap(){
    String document = "<lbs clear='ALL'><location lon='-7938675' lat='4367022' label='Toronto, ON' description='Go Leafs Go!' zoom='10'/></lbs>";
    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));

    }
    }

  4. #4
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: forcefully stop a thread

    When posting code use the CODE tags so it stays readable (see my sig).

    If it's just a question of stopping a thread, why don't you run a timer whose task interrupts the thread?

    I'm not really sure what the problem is here...

    The outcome of any serious research can only be to make two questions grow where only one grew before...
    T. Veblen
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured