How to destroy the worker thread

My problem is I have a swing client which has 2 buttons, search and cancel. In search button I am creating a new worker thread which will be calling my EJBs method. Thus I have an event thread and a worker thread running. Now when I click cancel button I want to interrupt my worker thread and screen should enable the search button but what happens is when I click cancel button it still continues with the worker thread even though I am calling workerthread.interrupt() method and this results in showing the result of the EJB's method on the screen. how can I prevent the worker thread to stop executing the ejb's method and come back to normal mode.

This application its a socket server, Im doing:
main {
Thread1 - createServer();
Thread2 - createLogging();
waitForServerShutDown();
the createServer method must be placed in a thread, its must not blocks the application because createLogging(); must be executed just after the server was created and createLogging(); doesnt blocks the application then... I must block the main{} to keeps application running

Similar Messages

  • How to destroy the component

    Hi friends...
    How to destroy the componenet.....
    Is it possible?....
    Thanks& regards
    Mathi

    hi,
    How to destroy the window through coding....
    Because
    component1
    view1--Nameis v1
    view2--Nameis v2
    component2
    view1--Nameis v3
    view2Nameis v2
    The diagram flow is
    view1>view2>view3>view1>view2-->view3
    But my project is work Like
    view1>view2>view3>view1>not go to view2-->again and again view1 to view3...
    Is any Possiblilities to destroy the componenet through coding...
    Thanks & regards
    Mathi

  • How to make the main() thread wait?

    I would like to know how to make the main() thread wait for another thread?If I use wait() method in main() method it says "non-static method wait() cannot be referenced from a static context",since main()
    is static.

    Here is an example how you may wait for a Thread in the main -
    but be careful, this is no real OO:
    public class WaitMain {
    // this is the thread class - you may also create
    // a runnable - I use a inner class to
    // keep my example simple
         public static class ThreadWait extends Thread{
              public void doSomething(){
                   synchronized(syncObject){
                        System.out.println("Do Something");
                        syncObject.notify();
              public void run(){
                   // sleep 10 seconds - this is
                   // a placeholder to do something in the thread
                   try{
                        sleep(10000);
                        doSomething();
                        sleep(10000);
                   catch(InterruptedException exc){
    // this is the object we wait for -
    // it is just a synchronizer, nothing else
         private static Object syncObject = new Object();
         public static void main(String[] args) {
              System.out.println("This will start a thread and wait for \"doSomething\"");
              ThreadWait t= new ThreadWait();
              t.start();
              synchronized(syncObject){
                   try{
    // this will wait for the notify
                        syncObject.wait();
                        System.out.println("The doSomething is now over!");
                   catch(InterruptedException exc){
              // do your stuff

  • How to retain the work item in inbox of user if user press the icon cancel?

    HI,
    we  are using a text editor in approval section of workflow where the user needs to enter the reason for apporval or rejection.
    the requirement is how to retain the work item in inbox of user if user press the icon cancel? there are two icons in editor,one is ok(tick marg) and cancel(cross mark).
    so when user dont enter any text in the editor and press on cancel icon,then approval/rejection should not authorize and work item will remain in the user's inbox .unless and untill he enters the text.
    i have tried   LEAVE TO TRANSACTION 'SBWP'.leave program etc but nothing is working.
    please guide me.
    thanks
    prsahu

    Hi,
    Go with Sangvir Singh suggestion.
    It also looks neater from a Business Process Modeling perspective. You continue the process flow only when a change has occurred.
    Kind regards, Rob Dielemans

  • How to find the work shift

    How to find the work shift of particular programe name.IF that pfgrame name is INXDSD.
    Any query ti fing out the work shift of this.
    please any body help me.

    Can you rephrase the question? Or provide some additional context?
    I assume this is somehow related to an Oracle database.
    - What is a "work shift"?
    - What is a "pfgrame"?
    - What "program name" are we talking about? Is this the name of a program that is connecting to an Oracle database? Or something else?
    Justin

  • How to enable EDT to interrupt the worker thread at any time?

    Hello, this is a Swing application - in order for EDT to be responsive, I do the graphical computation in another thread. The computation is very CPU intensive, and I notice the controls are a little jerky - that means the EDT can't get to event handling as fast as I would like. If I do a sleep in the computation thread, instead of work, then controls are smooth as silk - this proves to me that I am doing it right, it's just that the computation is hogging up the CPU. The initial priorities of both EDT and the computation thread are the same (4) - I tried to change the comp thread priority to minimal (1), with success. But even with the higher priority, EDT is still jerky. I even tried (I know gurus are gonna slap me for that) to change the priority of the EDT to max (10), from within the EDT, that was not successfull, the priority stayed at 4, but did not throw SecurityException.
    Anyway, how do I set it up, so that EDT can interrupt my thread, at any time, so EDT never has to wait for CPU?
    Mark

    But then I asked myself - then why, when I leave the computation thread sleeping, and still do "a little bit" of computation in EDT, it is smooth...
    the answer is quite amazing (at least to me, a newbie) - if the comp thread is not doing anything, the result is "simple" and ...
    it turns out, that if the thing that you are drawing, like a series of drawLine() calls, many of them, if the result is simple, like they together form a one long line, then Swing appears to do it faster, than if they do not form anything that can be simplified. It appears, that Swing merges your draw... calls as much as possible to actually make as few drawing calls as possible.

  • 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();
    }

  • How to delegate the work flow process.

    hi
    i was wondering if someone has taken a leave and he is replaced by an employee x,the work flow approval should be directly move to the employee x.
    but its not the case.as when someone is one leave,the workflow does not go to his replacement to approve
    Is there a way how to delegate the workflow process?"
    Thank you

    Hi,
    By identify the replacement in leave process, workflow process doesn't route to that person. I guess that replacement field is just for data capturing only. The approver should use delegate functionality available on notification responsibility to identify which process route to which person in a given time period.
    Thanks

  • How to refer the work order status value from a different transaction in the step handler?

    Hi All,
    I have a requirement to check the status of the work order from a different transaction before doing some logic in the current transaction. The following transactions are done to replicate the issue
    1)changing the status to ONSITE to edit the work order (transaction 1)
    2)Adding some information which will do some logic (transaction 2)
    3)Completing the work order (transaction 3)
    The transaction 2 will have some logic and will be executed only if the status is COMP but even though the status is COMP now (transaction 3) my condition check in the logic is showing as ONSITE status(transaction.status=ONSITE) and it fails. How can i get the latest status of the work order in the device? Please advice

    Hi Jason,
    The CompleteWorkOrderFinish sub action does have Apply action (screenshot 1) and the transaction definition (screenshot 2)of CompleteWorkOrderFix transaction with the only property Status which has the following settings (screenshot 3)
    Also I am trying to add a status property in EditMeterFitDetaisl transaction and update this value with the current status of the work order using object collections filtering with key value. Please let me know if that approach can be followed. Thanks

  • How do determine the work orders for a sales order?

    I'm forced to calculate our costs by sales order.  So for a given sales order number, how is this linked to the work order that created the items on the sales order?
    Thanks

    Hi,
    Check this:
    Re: Open Production Orders List with a Field from Sales Order
    Thanks,
    Gordon

  • How to configure the work manager java code to eclipse?

    Hello all,
                   I am working with the syclo work manager app. I have successfully installed all components required.
                   I imported the work manager mobile application and I want to import the standard work manager java code, what is the process to import java code into work space.
                   Guide me with some screen shots.
                   When I try to start the WM server it is giving me the following error:
    How to resolve the error.
    Please anyone provide me complete setup needed to run the work manager app smoothly.
    Please guide me.
    Thanks & Regards,
    Swaroopa.

    Swaroopa,
    That error is telling you the SAP JCo library cannot find one of the needed DLLs on the system.  The sapjco.jar loads two additional DLL files (sapjcorfc.dll and librfc32.dll).  Both should be installed by default into your ServerDev directory (assuming you are running Agentry 6.0.x).
    I would guess it is having trouble loading the librfc32.dll based on the message but confirm both are in the correct location.
    --Bill

  • How to set the working directory for reports in linux

    Hi All,
    Can you anyone help me to set the working directory for oracle application server 10g reports? I am using RHEL4 and AS10g. Actually i want to run my reports from my define
    working directory. How can I do this?
    Thanks in advance
    Arif

    Hi,
    your rep_srv.conf should look like something like
    +<?xml version = '1.0' encoding = 'ISO-8859-1'?>+
    +<!DOCTYPE server PUBLIC "-//Oracle Corp.//DTD Reports Server Configuration //EN" "file:D:\oracle\FRHome_1/reports/dtd/rwserverconf.dtd">+
    +<server version="10.1.2.0.2">+
    +<!--Please do not change the id for reports engine.-->+
    +<!--The class specifies below is subclass of _EngineClassImplBase and implements EngineInterface.-->+
    +<cache class="oracle.reports.cache.RWCache">+
    +<property name="cacheSize" value="50"/>+
    +<!--property name="cacheDir" value="your cache directory"-->+
    +<!--property name="maxCacheFileNumber" value="max number of cache files"-->+
    +<!--property name="ignoreParameters" value="parameter names to be ignored in constructing cache key, separated by comma ','"-->+
    +</cache>+
    +<engine id="rwEng" class="oracle.reports.engine.EngineImpl" initEngine="1" maxEngine="3" minEngine="0" engLife="50" maxIdle="30" callbackTimeOut="90000" jvmOptions="-Xmx512M -Xss512K">+
    +<!--property name="sourceDir" value="your reports source directory"/-->+
    +<!--property name="tempDir" value="your reports temp directory"/-->+
    +<!--property name="keepConnection" value="yes"/-->+
    +</engine>+
    +...+
    some more definitions
    +..+
    +<!--pluginParam name="proxy" type="file">proxyinfo.xml</pluginParam-->+
    +<pluginParam name="xmlpds" type="file">xmlpds.conf</pluginParam>+
    +<pluginParam name="jdbcpds" type="file">jdbcpds.conf</pluginParam>+
    +<pluginParam name="textpds" type="file">textpds.conf</pluginParam>+
    *<environment id="APP1">*
    *+<envVariable name="REPORTS_PATH" value="/application1/reports"/>+*
    *+</environment>+*
    *+<environment id="APP2">+*
    *+<envVariable name="REPORTS_PATH" value="/application2/reports"/>+*
    +</environment>+
    +</server>+
    The environment ids you can choose yourself and you have to put them in there yourself too (here I put two environments for two different applications "1" and "2").
    If you call a report from Forms, then you have to code something like
    ADD_PARAMETER(p_list,'ENVID',TEXT_PARAMETER,'APP1');
    Details depend on how you call your reports, my example is for using a parameter list and calling a report out of application1
    Hope that helps.
    Volker

  • How to find the working directory

    Hi all
    my csseditor is almost fully working but im having one slight problem
    my css images arent being displayed all the time (this is a bit confusing but...)
    when i reference the image via an address (http://localhost/tgheader.jpg) it works
    e.g. background-image:url('http://localhost/tgheader.jpg');
    if i reference the image via an exact path (C:/myimages/tgheader.jpg) it doesnt work
    e.g. background-image:url('C:/myimages/tgheader.jpg');
    and obviously it doesnt work if i just reference the image relatively
    e.g. backgroundimage:url('tgheader.jpg')
    so far your probably thinking what has this got to do with java, well i am wondering if it is not finding the image because maybe when i run the app it cant find working directories maybe or does the ap run from a temp directory maybe (or is it from the directory where the classes are run from) and if so if i put the images in that path then shouldnt the css know where the image is or when i render the html from a string does java omit the fact of exact paths?
    if anyone feels like this is too abstract from java to be posted here, then im sorry, im just not sure if it is a java problem or a css problem (because css works just fine using exact paths when it is run in a normal html ie environment)

    basically it is just a swing ap that runs offline
    open a css stylesheet (*.css) which is parsed into my
    stylesheet adt
    then my html header file (header.htm) is read into a
    string via getResourceAsStream
    (the header is everything that u get in a html file
    <html><head><title></title> up to <style)
    then i do a toString on my stylesheet adt to paste
    into the html string all of the styles in the
    stylesheet
    then i read in the footer info of the html with
    getResourceAsStream (footer.htm) and this contains
    the rest of the html document
    so my final html string is a complete html document
    including the styles
    i then load that string into my browser component
    which displays the html with the applied styles
    the program is just run locally and doesnt (and
    shouldnt) require any web serverok then sorry about my advice that make no sense :p
    In the light of this, I'm going to reread the whole thread ;-)

  • How to direct the Work Items in SBWP to different folders

    Hello All ,
    Is there a possibility of having a rule on the SBWP , so that the work items coming in to the inbox can be placed in different folders based on some grouping .
    I see 4 kinds of grouping :
    Grouped according to task
    Grouped according to content
    Grouped according to content type
    Grouped according to sort key
    Is there any help on how to use this . Any example given ?
    Do we have any other groupings on the workflow inbox other then the above ?
    Thank you very much for your valuable input ...

    As said above, the work items are automatically directed to these folders according to rules briefly explained here (and you can't change the rules): [sap library - workflow - inbox|http://help.sap.com/saphelp_nw70/helpdata/EN/ae/b82ccee10611d2a62f0060087a79ea/frameset.htm]
    In case you don't have work items in your inbox, use transaction SWUI_DEMO: used to start several demo workflows
    If you want a custom business workplace, see demo transaction SWLD_INPLACE1: a custom business workplace with one container (program of 210 lines)

  • How to hold the main thread, till response is received from the server?

    I have a program in which the GUI client(View program in Swings) sends a request to server (Manager program) , and waits for the response from Manager.
    The method used is waitForResponse() as follows
    <code>
    private void waitForResponse()
    m_blWaitFlag=true;
    //after response from manager m_blWait flag is set to false.
    while (m_blWaitFlag)
    try
    Thread.sleep(500);
    }catch(Exception r_ex)
    </code>
    And in notifyResponse() method, the wait flag is set to false
    as in,
    <code>
    public void notifyResponse(VcvResponse r_objResponse)
    m_blWaitFlag = false; //this line makes the thread to come out of the wait mode.
    </code>
    When I click a menu item, this request is sent and there is a wait for a response from manager.
    The problem is , this kind of waiting makes the system slow, and grey patches are seen immediately after clicking a menu item.
    Are there other ways of waiting??
    Thanks in advance

    When I click a menu item, this request is sent and there is a wait for a response from manager.This means you are using the GUI thread to send the request.
    The problem is , this kind of waiting makes the system slow, and grey patches are seen immediately after clicking a menu item.This means the GUI thread is waiting for the response. No GUI updates can occur while it is waiting.
    Are there other ways of waiting??Use another thread. e.g the main as you suggested. If you are using a callback, why do you have a thread waiting at all? WHy not do the things you would do when a response comes back in the call back?

Maybe you are looking for