Stop the running Thread

Hi
i am calling the thread .in the midlle of running thread i have to stop the thread .please help me .
my senario like . I am calling the scripts . i am wating certain period to complete the script exection . if the scripts are not available its still wating for a long time . so i am using the thread to execute the scripts and (main thread )checking each duration is completed or not . if the duration completed i am stoping the thread with Thread.Stop() method . but the thread still is alive . next time when i call Thread.Start() its throwing "java.lang.IllegalThreadStateException".
please help me this .
Thanks in advance
public class TestCaseScriptProcessor extends Thread {
public String execute(){
TestCaseScriptProcessor caseScriptProcessor = new TestCaseScriptProcessor();
caseScriptProcessor .start();// second time throwing java.lang.IllegalThreadStateException.
while (!isExpired) {
caseScriptProcessor.stop();
public void run() {
Edited by: 849614 on Jan 17, 2013 6:17 AM
Edited by: 849614 on Jan 17, 2013 6:22 AM

What exactly are you trying to do? Calling Thread.stop( ) is inherently a bad idea (see the Javadocs).
You are getting a IllegalStateException because Thread.stop( ) kills the thread, you would need to create a new thread to resume execution.
If what you are trying to do is pause execution, you probably want to redesign your thread's tasks into smaller chunks that can be launched separately. Alternatively, have the thread check it's interrupted state and if a flag was set block on a monitor until you want it to resume execution.

Similar Messages

  • How to stop the running infospoke

    Hi Experts,
    there is a infospoke is still running so long time, it's incorrect, i'll cancel it as kick off the dependenies, i have no idea to how to stop the running infospoke. Anybody could tell me how to do it. thanks in advance.

    hi denny,
       Go to SM37 , find the job , stop the process
    or
       To stop the job find the job with the help of the request name ( TC - SM37 ),then in the job Details find the PID .
    find the process in the process Overview (SM50 / SM51 ).
    Set the restart to NO and Cancel the process without core
    u can also see these threads that are already posted:
    stopping v3 run job LIS-BW-VB_APPLICATION_02_010
    how to cancel or change the background job which is scheduled
      In SM37, for the job , click on Step button. Then from the menu Goto > variant. You can see the process chain name here.
    sure it helps
    Thanks
    Varun CN

  • How to stop the running process chain

    How to stop the running process chains or infopackges...just qm status change is enought?

    BI - SM 37 - Kill the Job
    ECC - SM 50 - Kill the job

  • HT201365 How do I stop the running of programs in the background?  The old way of doing it doesn't work now.

    How do I stop the running of programs in the background?  The old way of doing it doesn't work now.

    How to Close Apps
    Double Tap the Home Button... Then swipe the App (not the icon) Upwards... Tap the Home Button when finished.
    From Here  >  http://support.apple.com/kb/HT4211

  • How to stop the 2nd thread when 1st thread caught exception.

    Hello Friends,
    I have written a java program using Thread.
    In this program i have created two separate threads.
    For example Thread1 and Thread2.
    During execution of both threads,
    If any exception comes on Thread1 or Thread2, the other thread should not be continued its execution. Suddenly the other thread has to interrupted its execution.
    How to do this. If any body know the way to do this, please help me.
    Rgds
    tskarthikeyan

    Try this. It was working Fine.
    public class ThreadComm {
         public static volatile boolean exceptionThrown= true;
         public static void main(String[] args) {
              Thread t1 = new Thread(new Runnable() {
                   public void run () {
                        try {
                             /*if (exceptionThrown) {
                                  System.out.println("First Thread Interrupted");
                                  return;
                             for(int i=1;i<=5000;i++){
                                  System.out.println("FirstThread>>"+i);
                                  if(i==2500) {
                                       throw new Exception("First Thread Interrupted");
                        }catch(Exception e) {
                             exceptionThrown = false;
              Thread t2 = new Thread(new Runnable() {
                   public void run() {
                        try {
                             /*if (exceptionThrown) {
                                  System.out.println("Second Thread Interrupted");
                                  return;
                             for(int i=1;i<=1000;i++){
                                  System.out.println("SecondThread>>"+i);
                                  if(i==777) {
                                       throw new Exception("Second Thread Interrupted");
                             int i=0;
                             while(exceptionThrown && i<=5000) {
                                  System.out.println("SecondThread>>"+i);
                                  if(i==4000) {
                                       throw new Exception("Second Thread Interrupted");
                                  i++;
                        }catch(Exception e) {
                             exceptionThrown = true;
              t1.start();
              t2.start();
    }

  • Stop a running thread

    I create a thread and while it is running i want to stop it but not wait what should i do to solve this problem.
    Edited by: phamthao on May 24, 2009 12:13 PM

    public class Example implements Runnable{
         private boolean isRunning, MISTAKE;
              isRunning = true;
              MISTAKE = false;
              Thread thread = new Thread(this);
              thread.start();
         public void run(){
              while(isRunning){
                   //do stuff
                   if (MISTAKE){
                        isRunning = false;
    }Pretty general

  • How to stop the running VSTO application

    Hi,
    I want to stop my Word/Excel 2010 C# VSTO application. 
    Is there any way to stop it by clicking on a button on the same application, command line option or keyboard shortcut.
    Thanks in advance.

    Hi,
    As your issue is related to VSTO, I'm moving your post to the VSTO forum for better supports. Thanks for your understanding.
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=vsto
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to 'STOP' a running java thread in J2ME?

    Dear All,
    How to 'STOP' a running java thread in J2ME?
    In the middleware viewpoint, for some reasons we have to stopped/destroyed the running threads (we have no information how these applications designed).
    But in J2ME, Thread.destroy() is not implemented. Are there other approaches to solve this problem?
    Thanks in advance!
    Jason

    Hi jason,
    Actually there are no methods like stop() and interrupt() to stop the threads in J2ME which is present in normally J2SE Environment.
    But the interrupt method is introduced in Version 1.1 of the CLDC.
    So, we can handle the thread in two ways.
    a) If it is of single thread, then we can use a boolean variable in the run method to hadle it. so when the particular boolean value is changed , it will come out of the thread.
    for eg:
    public class exampleThread implements Runnable
    public boolean exit = false;
    public void run()
    while(!exit)
    #perform task(coding whatever u needed)
    public void exit()
    exit = true;
    b) If it is of many threads then we can handle using the instance of the current thread using currentThread() method
    for eg:
    public class exampleThread implements Runnable
    public Thread latest = null;
    public Thread restart()
    latest = new Thread(this);
    latest.start();
    public void run()
    Thread thisThread = Thread.currentThread();
    while( latest == thisThread )
    #perform some tasks(coding part);
    public voi d stopAll()
    latest = null;
    while ( latest == thisThread )
    performOperation1();
    if( latest != thisThread )
    break;
    performOperation2();
    Regards,
    Prathesh Santh.

  • URG & IMP: How does one stop the Thread.currentThread?

    hi,
    I want to stop the current thread.
    Presently teh code used Thread.currentThread.stop()
    However stop() has been deprecated
    Thread.currentThread.interrupt() doesnot seem to help.
    If I try Thread.currentThread.isAlive() post tehinterrupt, it doesnot work as desired and teh thread is still active...
    Any pointers????
    We have alreday tried using the boolean volatile varible to stop the thread as recommended by sun and since this is the currentThread, it cannot be assigned to null.
    Thanks
    Priya

    hi,
    I want to stop the current thread.
    Presently teh code used Thread.currentThread.stop()Whyever would a thread want to deliver a stop() to itself.
    Did you mean that you wanted to stop() a different thread?
    As indicated in the (depreaction) documentation for stop(), using interrupt()
    is a better idea. However, that requires you to have a protocol
    where the receiver of the interrupt then reacts in an appropriate
    manner, i.e. interrupt() can be the basis for cooperative
    thread termination; it can't merely replace a stop() call
    in an existing application without any other changes.
    >
    However stop() has been deprecated
    Thread.currentThread.interrupt() doesnot seem to
    help.
    If I try Thread.currentThread.isAlive() post
    tehinterrupt, it doesnot work as desired and teh
    thread is still active...
    Any pointers????
    We have alreday tried using the boolean volatile
    varible to stop the thread as recommended by sun and
    since this is the currentThread, it cannot be
    assigned to null.Think about what you are trying to achieve. Did you want
    to just do a Throw() out of the current method, with (or
    without )a corresponding Catch() in some outer context)
    so that the you can unwind in case of an exceptional
    condition and have the thread exit?
    >
    Thanks
    Priya

  • Stopping a Running process in EPMA workspace.

    Anyone?
    I have about a dozen running process that are sitting idle. How can i stop them? this is production environment. I've restarted all the services, still there shows running. any solutions besides rebooting the server?
    Most of the process are HFM Re-deploy and export.
    Any solutions?
    Regards,
    Alex Mathew

    Hi, I'm been unable to kill a running/executing thread. Here's how I created the thread:
    EvoluteRun er = new evolutionary.EvoluteRun();
    Thread t1 = new Thread(er);
    then here's how I'm trying to kill the executing thread:
    private void StopButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if ( (t1 != null) && (t1.isAlive()) ) {
    System.out.println("going to suspend");
    t1.suspend();
    System.out.println("stop");
    To my amazement, the stop printouts only comes up after the running thread had been finished (finished the run()) althogh the stop button had been clicked (many times as well), there seems no effect no the executing thead. Please help.
    Thanks

  • Running thread behaviour on calling interrupt?

    if a thread T1 is running and interrupt is called on this thread,there will be no impact on thread T1 processing/behaviour. To handle this
    we have to call if (Thread.interrupted()) inside run method of thread T1 right?
    Interrupt will have impact when thread is under wait,sleep or join(or methods that throw InterruptedException),Right?
    In above question , impact refers to the case when InterruptedException will be thrown.
    Asked the question at http://www.coderanch.com/t/545582/threads/java/Impact-interrupt-Running-thread but did not get satisfactory reply though i have been thru api doc.

    Interrupting a thread sets a flag for that thread. Setting that flag will cause some blocking operations to throw an exception. e.g. sleep, wait, NIO read. Unless you do one of those operations, setting the flag doesn't do anything which is a problem for those who hope to stop a running thread in an untrusted third party library. ;)

  • OBIEE Server Hangs how to stop the process?

    Hi,
    I schedule one report in BI publisher and in history its showing status as ‘Running’ from a long time, I want to terminate that process and want to stop the running report.
    But as I don’t no much about OBIEE I am unable to do that. Could you please help me with this.
    Thank you.

    Hi,
      At times even I have faced this situation.  During those times, running the Function module RSPC_PROCESS_FINISH by passing the right parameters came to my rescue.
    Regards,
    Raj

  • How to stop the BI Publisher Job

    Iam scheduling a job to run a report from BI publisher . I want to know if there is a way to stop the running job and re-start it via BI publisher ?

    Hi;
    What kind of job this, its running manualy or from crontab?
    Let us say you are taking rman backup wiht crontab entery. So login your server than
    ps -ef|grep rman
    This will bring you OS PID than issue is
    kill -9 PID
    Regard
    Helios

  • Error running "threads" in jdb.

    When I run jdb against WebLogic SP2 running in Sun JVM 1.3.1_02, and I type
    the "threads" command to list the running threads, I get this exception:
    Group system:
    Internal exception:
    java.lang.StringIndexOutOfBoundsException
    at java.lang.StringBuffer.insert(StringBuffer.java:808)
    at
    com.sun.tools.example.debug.tty.Commands.printThreadGroup(Commands.ja
    va:295)
    at
    com.sun.tools.example.debug.tty.Commands.commandThreads(Commands.java
    :303)
    at com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:351)
    at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:625)
    at com.sun.tools.example.debug.tty.TTY.main(TTY.java:924)
    Any ideas?
    Thanks,
    Bob

    When things like this happen, usually the right place to search for an answer
    is Sun's bugparade. Searching for 'com.sun.tools.example.debug.tty.Commands.printThreadGroup'
    results in:
    http://developer.java.sun.com/developer/bugParade/bugs/4432376.html
    Bob Lee <[email protected]> wrote:
    When I run jdb against WebLogic SP2 running in Sun JVM 1.3.1_02, and I type
    the "threads" command to list the running threads, I get this exception:
    Group system:
    Internal exception:
    java.lang.StringIndexOutOfBoundsException
    at java.lang.StringBuffer.insert(StringBuffer.java:808)
    at
    com.sun.tools.example.debug.tty.Commands.printThreadGroup(Commands.ja
    va:295)
    at
    com.sun.tools.example.debug.tty.Commands.commandThreads(Commands.java
    :303)
    at com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:351)
    at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:625)
    at com.sun.tools.example.debug.tty.TTY.main(TTY.java:924)
    Any ideas?
    Thanks,
    Bob--
    Dimitri

  • Background java thread stops after running the fx thread

    in my server thread i am accepting a file . so i used Platform.runLater() to display a scene that gets confirmation from user. But when it reach the scene it is not going back to the server thread.
    class server implements Runnable
    public void run()
    while(true)
    // accepts client
    Platform.runLater(new Runnable(){    //  after this fx its not goin to the while
    // display confirmation message
    // writing the file
    }

    Post a bit more code, calling Platform.runLater() will not cause this behaviour. In fact, it should immediately return and continue with the while. You can add print statements if you want to be sure what is happening.
    The only reason I could think of is if the while(true) is already on the FX application thread but that seems unlikely.

Maybe you are looking for

  • IOS 7.0.3 will not correctly "manually manage music and videos" any more?

    So, on all my iOS devices, I have always used "Manually manage music and videos" to drag albums from my iTunes library to my iPhones. I then use iTunes to delete the albums and replace them with others (I have a lot of music). With the iOS 7.0.3 upda

  • About the Mac OS X 10.4.11 Update

    Here is what Apple expects you to read before applying this upgrade. The key line is to backup your system. Important: Please read before installing You may experience unexpected results if you have third-party system software modifications installed

  • Unable to Display Background Graphic From HTML File Generated from AI File

    I am trying to figure out if this is a MAC OS X or Safari issue. I have already a message into the author of the plug-in as well as created a posting on the Adobe Forum. I am following a tutorial on Lynda.com called "Design the Web: Illustrator to An

  • Efficient way to change site template

    hi all, IHAC, the customer want to build a home page with big difference from wc default site templates, I know the solution is to use site template, with this solution, even I disabled 8 other components in extendwebcenterspaces, build and deploy st

  • How install flash player for linux

    I need command information for install in linux system ! thanks