How to stop Native Meto running in separate thread?

I have a long working NM and run it in separate thread using SwingWorker class. If I want to stop that metod, i use interrupt(), but it seems to be a wrong way. It looks like NM go on working, and when I call other NM it throws an Access Violation Exception.
Is there any ideas?
Thank you. Charis.

The interrupt() method does not stop the thread. It sets a flag. Are you checking that flag in your native code?

Similar Messages

  • Having 2 objects running in separate threads

    I am accessing cobol programs using the microfocus runtime for java. The problem with it is that a you can only run one instance of a cobol program at the same time, unless they are in separate threads.
    Example:
    CobolTextSearch cobol1 = new CobolTextSearch();
    CobolTextSearch cobol2 = new CobolTextSearch();
    cobol1.execute("FAMILY");
    cobol2.execute("HISTORY");
    System.out.println(cobol1.getRecord());
    System.out.println(cobol2.getRecord());The output of this program results in HISTORY for cobol1 and HISTORY for cobol2. Where as if they were run in separate threads, I would have got FAMILY for cobol1.
    So my question is, is there any way I can run these two objects in separate threads so that any time I access the object it will be in its own thread? I cant just run them in separate threads on the execute because each getRecord is interfacing with cobol. After execute I want to be able to read values from the cobol files to see if they match without having to read each record into memory on the java side.

    No you are not missing anything, you just create a new thread each time you run something or you have to make a setter method to accept parameters for the next run and then a seperate method to actually make your routine execute.
    public void setTask(String s){
      task2Execute = s; //task2Execute is global to the methods
    public boolean runTask(){
      CobolTextSearch cobol = new CobolTextSearch();
      cobol1.execute(task2Execute);
    //  other logic
    }Here is what the docs say about threads: A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.

  • How to stop the manually running job

    Hi,
    I have to stop a job that is run by user manually. I checked on net but did not find the way to stop the existing running job.
    Please suggest.
    Thanks,
    Gulshan

    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

  • Running in separate thread??

    Hi
    I have a code which generates a pdf file. What i wan is for it to run in a separate thread. The filling and creation of the pdf file should be running while i am doing other stuffs.. just like in downloading. the user can browse or do other things in the mean time while waiting.. when the pdf file is ready to be viewed, then the program should interupt whatever the user is doing and pop up a pdf viewer to display the file.
    Is there any way to call the pdf viewer in my code? And how should i do the interrupt? Plus, how do i specify that the pdf creation should run in a separate thread?
    thanks in advance.
    tbozu

    alright, handling the interrupt is highly dependant on the rest of your application, so I won't touch that one, but.
    To create your file in a different thread, wrap the method in it's own thread, so it would look similar to
    new Thread() {
    public void run() {
    writeMyFile(); // your method here
    }.start();then, to start the pdf viewer, try using the Runtime.exec() utilities.
    good luck to you!

  • Export from Crystal Reports 2008 viewer fails if run on separate thread

    I have a windows desktop application written in Visual Basic using Visual Studio 2008.  I have installed and am trying Crystal Reports 2008 to run a report.  Everything seems to work well except that when I preview a report (using the viewer control) and click the export button found in the upper left corner of that control, I get the following message:
    Error 5: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made.  Ensure that your Main function has STAThreadAttribute marked on it.  This exception is only raised if a debugger is attached to the process.
    I am a little confused on what to do exactly.  Is the problem because I am running in the Visual Studio 2008 IDE?  It says this exception is only raise if a debugger is attached to the process.  No, I tried running it outside the IDE.  The exception wasn't generated but the application hung when the button was clicked.
    It says the current thread must be set to single thread apartment (STA) mode.  If the report is run on its own thread, is the "current" thread the thread the report is running on or is the main application's UI thread?  I don't think I want to set my main application to single thread apartment mode because it is a multi-threaded application (although I really don't know for sure because I am new to multi-threaded programming). 
    My objective is to allow reports to run asynchronously so that the user can do other things while it is being generated.  Here is the code I use to do this:
        ' Previews the report using a new thread (asynchronously)
        Public Sub PreviewReportAsynch(ByVal sourceDatabase As clsMainApplicationDatabase)
            Dim backgroundProcess As System.ComponentModel.BackgroundWorker
            ' Start a new thread to run this report.
            backgroundProcess = New System.ComponentModel.BackgroundWorker
            Using (backgroundProcess)
                ' Wire the function we want to run to the 'do work' event.
                AddHandler backgroundProcess.DoWork, AddressOf PreviewReportAsynch_Start
                ' Kick off the report asynchronously and return control to the calling process
                backgroundProcess.RunWorkerAsync(sourceDatabase)
            End Using
        End Sub
        Private Sub PreviewReportAsynch_Start(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
            ' The source database needed to call preview report was passed as the only argument
            Call PreviewReport(CType(e.Argument, clsMainApplicationDatabase))
        End Sub
        ' Previews the report.  From the preview window, the user can print it.
        Public Function PreviewReport(ByVal sourceDatabase As clsMainApplicationDatabase) As FunctionEndedResult
            Dim errorBoxTitle As String
            Dim frmPreview As frmReportPreview
            ' Setup error handling
            errorBoxTitle = "Preview " & Name & " Report"
            PreviewReport = FunctionEndedResult.FAILURE
            On Error GoTo PreviewError
            ' Set up the crxReport object
            If InitializeReportProcess(sourceDatabase) <> FunctionEndedResult.SUCCESS Then
                GoTo PreviewExit
            End If
            ' Use the preview form to preview the report
            frmPreview = New frmReportPreview
            frmPreview.Report = crxReport
            frmPreview.ShowDialog()
            ' Save any settings that should persist from one run to the next
            Call SavePersistentSettings()
            ' If we got this far everything is OK.
            PreviewReport = FunctionEndedResult.SUCCESS
    PreviewExit:
            ' Do any cleanup work
            Call CleanupReportProcess(sourceDatabase)
            Exit Function
    PreviewError:
            ' Report error then exit gracefully
            ErrorBox(errorBoxTitle)
            Resume PreviewExit
        End Function
    The variable crxReport is of type ReportDocument and the windows form called 'frmPreview' has only 1 control, the crystal reports viewer. 
    The print button on the viewer works fine.  Just the export button is failing.  Any ideas?

    Hi Trevor.
    Thank you for the reply.  The report document is create on the main UI thread of my application.  The preview form is created and destroyed on the separate thread.  For reasons I won't get into, restructuring the code to move all the initialization stuff inside the preview form is not an option (OK, if you a really curious, I don't always preview a report, sometimes I print and/or export it directly which means the preview form isn't used).
    What I learned through some other research is that there are some things (like COM calls and evidently some OLE automation stuff) that cannot be run on a thread that uses the MTA threading model.   The export button probably uses some of this technology, thus the message stating that an STA threading model is required.  I restructured the code as follows to accomodate this requirement.  Here is a sample:
    ' Previews the report using a new thread (asynchronously)
        Public Sub PreviewReportAsynch(ByVal sourceDatabase As clsMainApplicationDatabase)
            Dim staThread As System.Threading.Thread
            ' Start the preview report function on a new thread
            staThread = New System.Threading.Thread(AddressOf PreviewReportAsynchStep1)
            staThread.SetApartmentState(System.Threading.ApartmentState.MTA)
            staThread.Start(sourceDatabase)
        End Sub
        Private Sub PreviewReportAsynchStep1(ByVal sourceDatabase As Object)
            Dim staThread As System.Threading.Thread
            ' Initialize report preview.  This includes staging any data and configuring the
            ' crystal report document object for use by the crystal report viewer control.
            If InitializeReportProcess(DirectCast(sourceDatabase, clsMainApplicationDatabase)) = FunctionEndedResult.SUCCESS Then
                ' Show the report to the user.  This must be done on an STA thread so we will
                ' start another of that type.  See description of PreviewReportAsynchStep2()
                staThread = New System.Threading.Thread(AddressOf PreviewReportAsynchStep2)
                staThread.SetApartmentState(System.Threading.ApartmentState.STA)
                staThread.Start(mcrxReport)
                ' Wait for step 2 to finish.  This blocks the current thread, but this thread
                ' isn't the main UI thread and this thread has no UI anymore (the progress
                ' form was closed) so it won't matter that is it blocked.
                staThread.Join()
                ' Save any settings that should persist from one successful run to the next
                Call SavePersistentSettings()
            End If
            ' Release the crystal report
            Call CleanupReportProcess(DirectCast(sourceDatabase, clsMainApplicationDatabase))
        End Sub
        ' The preview form must be launched on a thread that use the single-threaded apartment (STA) model.
        ' Threads use the multi-threaded apartment (MTA) model by default.  This is necessary to make the
        ' export and print buttons on the preview form work.  They do not work when running on a
        ' thread using MTA.
        Public Sub PreviewReportAsynchStep2(ByVal crxInitializedReport As Object)
            Dim frmPreview As frmReportPreview
            ' Use the preview form to preview the report.  The preview form contains the crystal reports viewer control.
            frmPreview = New frmReportPreview
            frmPreview.Report = DirectCast(crxInitializedReport, ReportDocument)
            frmPreview.ShowDialog()
        End Sub
    Thanks for your help!
    Andy

  • How to create a JTree in a separate thread?

    Hi. I am writing a Swing application which has a JTree that is made up of company parent nodes and employee child nodes. My problem is that the data for this JTree is loaded from the database and this process takes a long time making the loading time of the app too slow. I think that this process should probably be done in a separate thread. This would let the gui load much quicker and then when the thread finishes it can update the graphics to display the JTree. I have the code for the JTree all done and it works but I need help on putting it in a separate thread and running the thread. I am having trouble with this. Any help would be greatly appreciated.
    Eugene P.

    Thank you for responding to my question but I actually figured out a solution already. I used the SwingWorker class. When the program loads I just display a simple JTree with just the names of the companies without the employees. This takes almost no time to load. Then in the construct() method of the SwingWorker class I run the query to get the employee names and then create the new JTree that has the firms and the employees. In the finished() method of the SwingWorker class I update the gui. This whole process is running in a separate thread while the gui is already loaded so it works beautifully.

  • Stop query on run on report startup

    Hi
    how to stop query on run on interactive report startup
    Thanks

    Hello,
    What do you mean exactly by "interactive report startup" ?
    Else, if you want to stop a running query you may kill the corresponding session.
    So with OEM or by querying the v$session you may identify the session (sid, serial#) of the query
    to stop. For instance:
    alter session set nls_date_format = 'DD-MM-YYYY HH24:MI:SS';
    select sid, serial#, status, schemaname, osuser, program, sql_id, logon_time
    from v$session;Then, you may execute the following statement so as to KILL the session:
    alter system kill session '<sid>,<serial#>';You may find some examples on the link below:
    [http://www.psoug.org/reference/kill_session.html]
    Hope this help.
    Best regards,
    Jean-Valentin

  • Timer in separate Thread.

    Hi.
    In my application i have a timer use to tick after every second and update a lable on UI. problem i was facing was that when time is enable none of the touch event was working.
    I googled it and found that i have to call timer function from another thread..
    after some effort i manage to run a separate thread. but now i m facing problems in calling a timer function here is the code.
    Create Thread
    myThread = [[NSThread alloc] initWithTarget:self selector:@selector(SapThread:) object:nil];
    [myThread start];
    SapThread Function....
    - (void)SapThread:(id)info {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSTimer *appTimer = [NSTimer scheduledTimerWithTimeInterval:(1/20) target:self selector:@selector(UpdateTime) userInfo:nil repeats:YES];
    [pool release];
    UpdateTime Function for timer
    -(void) UpdateTime
    //set lable value.
    problem is this that UpdateTime function never called.
    Thankz in advance
    Muhammad Usman Aleem

    As I tried to explain above, I didn't expect your code to work after you corrected the firing method signature.
    Your detached thread doesn't run until you release your myThread object. It terminates when execution reaches the end of your SapThread method. That's why the timer never fires when you run it in that thread.
    In any case, I think sptrakesh is absolutely correct. There's no reason a timer in the main thread should prevent you from catching touch events. So I think you have two major points of confusion:
    1) Your thread isn't doing anything, since it terminates before the timer ever fires once;
    2) You have mis-diagnosed the problem with the touch events and don't need a new thread. I.e. even if you got a detached thread working to fire your timer, that's not going to solve your touch problem.
    I think bringing a new thread into the mix has gotten you in over your head and taken your attention away from the primary problem. So take sptrakesh's advice. Put the timer back into the main thread and focus on why you're not catching the events you want.

  • How to stop as files from running until a certain frame

    Hi all,
    I have a simple flash game with two frames at the moment.
    Most of the stuff that happens is in as files linked to
    different movie clips.
    I orignially only had one frame my background frame and when
    testing I just press ctl+enter and bamm away it goes the
    actionscript runs as soon as the movie/game starts and ergo the
    game plays.
    My problem is this, I now want to have a start/home frame at
    the beginning (of course) which has the start game button on which
    when clicked THEN starts the game.
    Currently the game starts in the first frame along with the
    start button :(
    How do I stop the game running straight away and my first
    frame only contains the start button, which when clicked then goes
    to the 2nd frame and starts the game?
    Reagrds,
    Red.

    A friend resolved the issue for me;
    By renaming the main contrustor and calling this in the start
    button Example action script applied to the button:
    START OF ACTION SCRIPT
    import flash.events.MouseEvent;
    stop();
    startBTN.addEventListener(MouseEvent.CLICK, startClick);
    function startClick(event:MouseEvent):void
    trace ("Button clicked");
    gotoAndStop(2);
    gameGo();
    /*gameGo() is the renamed main document class, renaming it
    prevents it from been run instanly
    and it is called from the button*/
    END OF ACTION SCRIPT

  • How to stop a running job in 10g Scheduler?

    The following is a duplicate post. I posted the following to the general database forum before seeing that otn has a new scheduler forum:
    I am not able to find in the Admin Guide a method to stop a currently running instance of a job in the 10g scheduler.
    In 9i, I run the following script calling DBMS_JOB.broken and DBMS_JOB.remove to shut down currently running jobs:
    DECLARE
    jobid NUMBER;
    CURSOR c1
    IS
    SELECT job
    FROM dba_jobs
    WHERE priv_user = 'ME';
    BEGIN
    OPEN c1;
    LOOP
    FETCH c1
    INTO jobid;
    EXIT WHEN c1%NOTFOUND;
    DBMS_JOB.broken (jobid, TRUE);
    COMMIT;
    DBMS_JOB.remove (jobid);
    COMMIT;
    END LOOP;
    CLOSE c1;
    END;
    How may I create similar code to shut down currently running jobs using DBMS_SCHEDULER in 10g? According to the Admin Guide, disabling jobs with the force option will still allow the job to finish.
    How can I terminate a running job in 10g?

    You can stop a currently running job using the STOP_JOB api.
    STOP_JOB Procedure
    This procedure stops currently running jobs or all jobs in a job class. Any instance of the job will be stopped. After stopping the job, the state of a one-time job will be set to SUCCEEDED whereas the state of a repeating job will be set to SCHEDULED or COMPLETED depending on whether the next run of the job is scheduled.
    Syntax
    DBMS_SCHEDULER.STOP_JOB (
    job_name IN VARCHAR2
    force IN BOOLEAN DEFAULT FALSE);
    Parameters
    Table 83-44 STOP_JOB Procedure Parameters
    Parameter Description
    job_name
    The name of the job or job class. Can be a comma-delimited list. For a job class, the SYS schema should be specified.
    If the name of a job class is specified, the jobs that belong to that job class are stopped. The job class is not affected by this call.
    force
    If force is set to FALSE, the Scheduler tries to gracefully stop the job using an interrupt mechanism. This method gives control back to the slave process, which can update the status of the job in the job queue to stopped. If this fails, an error is returned.
    If force is set to TRUE, the Scheduler will immediately terminate the job slave. Oracle recommends that STOP_JOB with force set to TRUE be used only after a STOP_JOB with force set to FALSE has failed.
    Use of the force option requires the MANAGE SCHEDULER system privilege.
    Setting force to TRUE is not supported for jobs of type executable.
    Usage Notes
    STOP_JOB without the force option requires that you be the owner of the job or have ALTER privileges on that job. You can also stop a job if you have the CREATE ANY JOB or MANAGE SCHEDULER privilege.
    STOP_JOB with the force option requires that have the MANAGE SCHEDULER privilege.

  • How can I debug a sequence that has a subsequence is running in a separate thread?

    Hi,
    How can I debug a sequence that has a subsequence is running in a separate thread?
    I have to have a continues check for a  digital in signal to be able to terminate the sequence if a physical button is pushed.
    This is running in a separate thread, but this way I cannot debug the main sequence.
    Is there any workaround for this?
    Thanks,
    Andras

    This KB might help you:
    http://digital.ni.com/public.nsf/websearch/46D1E157756C37E686256CED0075E156?OpenDocument
    Let me know if this does not help.
    Allen P.
    NI

  • 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 PROCESS CHAIN WHICH IS RUNNING IN THE PRODUCTION?

    HI ALL,
    CAN ANYONE TELL ME HOW TO STOP THE PROCESS CHAIN WHICH IS RUNNING DAILY AT 5.00 PM. I NEED TO STOP THE PROCESS CHAIN FOR COUPLE OF DAYS AND THEN RESTART IT AGAIN.
    cAN ANYONE TELL ME THE PROCEDURE TO STOP THE ENTIRE PROCESS CHAIN RUNNING IN THE PRODUCTION.
    THANKS
    HARITHA

    Hi,
    First and foremost let me advice you to be very careful while doing this.
    For Rescheduling
    RSPC> chain > Goto > Planning view and
    click on Execution tab > select > Remove from Schedule and then in Maintain variant of start process reschedule for the day you require it to run.
    For terminating active chain
    You can start from SM37, find the process WID/PID then go to SM50 or SM51 and kill it. Once its done come back to RSMO and check the request, it should be red but again manually force to red and save by clicking on the total status button in the status tab. This shuld ensure that the process is killed properly.
    The next step will be to go to targets that you were loading and remove the red requests from those targets.
    Note: For source system loads you may have to check if the request is running in the source system and kill if needed and pull it again.
    But for BW datamart delta loads u may have reset the datamarts in case u are going to pull the delta again.
    Re: Kill a Job
    Re: Killing a process chain.
    Regards,
    JituK

  • 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

  • How to stop the restructuring (ran manually)  which is running in the backg

    How to stop the restructuring (ran manually) which is running in the background.
    Tried stop the data base from EAS , but got error message saying that it is not acceptiong any commands.

    The only way I know to do it is to stop the application through task manager(Windows) or Kill(Unix). First you have to figure out what PID it is, then kill it. It does come with risk of corrupting the application depending on what step it is in. If you go this route, you should clean up the new created temporary files (Otn, Esn, etc) Some newer versions don't need this last step and will clean up when the application restarts, but I'd rather make sure things look good myself.

Maybe you are looking for

  • Problem using two displays...

    So I'm running my G5 with OSX 10.4.10 with a Radeon 9800 XT. I have two displays connected. A 23" Apple Cinema display conneded, via a Belkin ADC to DVI adaptor, to the ADC port. The second display is a Princeton VL 1919 connected directly to the DVI

  • Std Payment Terms in SAP

    Hi Wat are all the std payment terms in SAP. Vijay

  • "WRITE CODE FOR ME"

    SALAM COMPUTER SIR, I AM STUDENT OF COMPUTER SOFTWARE ENGINEERING .PLEASE HELP ME ABOUT I SEND YOU PICTURE OF MY PROJECT.PLEASE YOU MADE CODING FOR THE PICTURE IN JAVA LANGUAGE.PLEASE YOU GIVE ME SOURCE CODE OF THIS PROJECT PICTURE IN JAVA LANGUAGE.M

  • Update procedure in JDBC Receiver

    Hi, I am Working on Idoc to JDBC Scenario. I need to work with Insert and update procedure. When i send the Idoc the scenario is succesful in inserting the data. But when i am resending the Idoc, the scenario is not executing in updating the record.

  • CO Account Assignment

    Dear experts, While posting to cost elements, the system gives the following error: Account XXXX requires an assignment to a CO object Message no. KI235 Diagnosis You have not defined a CO account assignment for an account that is relevant to cost ac