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.

Similar Messages

  • 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

  • How to find workarea ID for the work area name.

    Hi Experts..
    How to find workarea ID for the work area name.(Work area name CCIHT_WAH-WAID and I want to fetch characteristic data from table AUSP matching the OBJEK field,but I only have Work area name).Can anybody help me to find tables or relationship between Workarea ID and Workarea name for the same.I am using TCODE - CHIB02.Once I select a workarea and click on IHS Data button,I get data for that workarea.I need to find where this data comes from and How is this fetched.
    Points would be rewarded for helpful answers..
    Thanks
    Kunal Halarnakar

    U want to fetch the workarea description ?
    we can fetch it from CCIHT_WALD table with the RECN value.
    The informations are stored in AUSP table with the characterstic(ATINN) value.

  • I have a new iPhone for work, set up on a new iTunes account (PC).  I was told i can associate it to my home iTunes account (iMac) but don't know how.  I want to save the work related apps as well.  Any advice?  Thanks

    I have a new iPhone for work, set up on a new iTunes account (PC).  I was told i can associate it to my home iTunes account (iMac) but don't know how.  I want to save the work related apps as well.  Any advice?  Thanks

    Thanks. I messed up with my husbands iphone because I was told the wrong thing. Now everytime I sync his phone it makes it look just like the other phone I had. Do you know how I can fix taht for his phone? Any settings I can turn off that will prevent all of my apps/contacts, etc from auto populating his phone?

  • How to enable Print Preview with the Envy 5530

    How to enable Print Preview on the Envy 5530

    Hi,
    A print preview is not offered by the current HP software as older software versions provided.
    A preview is only available if the application you are printing from include a such, it is not provided by the printer driver itself.
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • How to add empty coloumn in the work sheet

    Hi
    how to add empty coloumn in the work sheet for taking notes after getting print out the work sheet
    Regards
    Manikandan

    And if you want the column to be a certain width, then just create that calculation with spaces instead (ie: calc_junk = ' ' ).
    Russ

  • Why can't I interrupt the main thread from a child thread with this code?

    I am trying to find an elegant way for a child thread (spawned from a main thread) to stop what its doing and tell the main thread something went wrong. I thought that if I invoke mainThread.interrupt() from the child thread by giving the child thread a reference to the main thread, that would do the trick. But it doesn't work all the time. I want to know why. Here's my code below:
    The main class:
    * IF YOU RUN THIS OFTEN ENOUGH, YOU'LL NOTICE THE "Child Please!" MESSAGE NOT SHOW AT SOME POINT. WHY?
    public class InterruptingParentFromChildThread
         public static void main( String args[] )
              Thread child = new Thread( new ChildThread( Thread.currentThread() ) );
              child.start();
              try
                   child.join();
              catch( InterruptedException e )
    // THE LINE BELOW DOESN'T GET PRINTED EVERY SINGLE TIME ALTHOUGH IT WORKS MOST TIMES, WHY?
                   System.out.println( "Child please!" );
              System.out.println( "ALL DONE!" );
    The class for the child thread:
    public class ChildThread implements Runnable
         Thread mParent;
         public ChildThread( Thread inParent )
              mParent = inParent;
         public void run()
              System.out.println( "In child thread." );
              System.out.println( "Let's interrupt the parent thread now." );
              // THE COMMENTED OUT LINE BELOW, IF UNCOMMENTED, DOESN'T INVOKE InterruptedException THAT CAN BE CAUGHT IN THE MAIN CLASS' CATCH BLOCK, WHY?
              //Thread.currentThread().interrupt();
              // THIS LINE BELOW ONLY WORKS SOMETIMES, WHY?
              mParent.interrupt();
    }

    EJP wrote:
    I'm not convinced about that. The wording in join() suggests that, but the wording in interrupt() definitely does not.Thread.join() doesn't really provide much in the way of details, but Object.wait() does:
    "throws InterruptedException - if any thread interrupted the current thread +before+ or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown."
    every jdk method i've used which throws InterruptedException will always throw if entered while a thread is currently interrupted. admitted, i rarely use Thread.join(), so it's possible that method could be different. however, that makes the thread interruption far less useful if it's required to hit the thread while it's already paused.
    a simple test with Thread.sleep() confirms my expected behavior (sleep will throw):
    Thread.currentThread().interrupt();
    Thread.sleep(1000L);

  • Firefox does not know how to open this address because the protocol (Sims3) with any program connects

    Firefox does not know how to open this address because the protocol (Sims3) with any program connects
    can you help me plz

    Was the message sent from Microsoft Outlook? When you embed an image in a message in Outlook (at least up to version 2003), it creates a hidden attachment for the image and then inserts a "cid" reference to it. If the attachment gets stripped for any reason then the "cid" reference is useless: Outlook does not store the original URL or path to the image.
    Edit: By the way, which webmail site has this problem?

  • How to check data type of the field symbol at run time

    Hi,
    My code is as following:
          LOOP AT <fs> ASSIGNING <wa_covp_ext>.
            ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
            IF sy-subrc = 0.
              ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
              IF sy-subrc = 0.
                  SELECT SINGLE sname INTO <f_zzname> FROM pa0001
                                WHERE pernr = <f_pernr>
                                AND endda GE sy-datum
                                AND begda LE sy-datum.
             ENDIF.
          ENDIF.
        ENDLOOP.
    This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
    How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.

    check this ...
    write describe statement  ...
    field-symbols : <f_zzname> .
    data : sname like pa0001-sname,
           typ(10).
    assign sname to  <f_zzname>.
    describe  field <f_zzname> type typ.
    write : typ. <-- typ contains character type in this case ..
    U can check if typ is of character(C) if so .. write the select statement ...

  • Is there any way to interrupt the sleeping thread ?

    Is there any way to interrupt the sleeping thread ?
    regards,
    namanc

    Thread.interrupt, very
    sneakily hidden by being in the javadocs under the
    class you know you're using, as a method named by what
    you want to do.:o)
    Here's more:
    Java's Thread Tutorial
    JavaWorld: Introduction to Java threads
    IBM: Introduction to Java threads
    Google: java+threads+tutorial

  • I have been given a MacBook Pro.  How do I transfer everything to the new computer?  Last time I upgraded, I lost most of my iTunes

    How do I transfer everything to the new computer?  Last time I upgraded, I lost most of my iTunes, and some of my desktop stuff.
    My MacBook has OS X 10.6.8
    the "new" MacBook Pro has OS X 10.5.8

    Migration Assistant 

  • How to stop Firefox incessantly interrupting my work by trying to install an update incompatible with the Google toolbar which I depend on.that does nor

    Dear Sirs,
    How can I stop Firefox from incessantly interrupting my work by trying to install an update that is incompatible with the Google toolbar which I depend on. Not knowing any better, I trustingly allowed the installation the first time the update notice appeared. It crippled my Internet routines. The toolbars did not work and the bookmarks as well as all the history entries were lost, I have had to reinstall my previous Firefox 4.0.1 and start all over again.

    Hi chib60,
    Sorry you are having so much trouble.
    Dealing with your last comment first ''"Copy and paste the information from Help > Troubleshooting Information." Why? How? This is ridiculous info - it has no logic or sense to it like most of your advice. ''
    If you look to the right you will see a link for 'more system details' that is where such troubleshooting information appears, and it can sometime be helpful.
    I am using firefox on a couple of old XPs without problems. Obviously crashing is not expected behaviour, but please try to think of firefox as two separate parts the basic browser and all the additional software as addons and plugins.
    It may be rather unrewarding trying to track down the cause of a crash using crash information, the best way forward is probably to start using it in[[safe mode]] and with no plugins installed.
    * see also [[basic troubleshooting]]
    If firefox is recommended by your university, why not try it out on one of their computers, presumably it is installed on the university computers available in the library etc, that should at least convince you that it does work.
    I hope the problem is not malware, but if it is all the personal computers you try, a possibility that can not be discounted is that it is some form of malware affecting those computers.
    Have you tried Internet Explorer, that will be installed on your XP by default I imagine, does that work ?

  • How to Enable JMX Console in the Weblogic 10.3

    Note : Sorry, i am cross posting this thread from "management", but this is extremely urgent for me and i did not get any response from yesterday. Hope to have a solution atleast from this group.
    I have an application that is JMX enabled. It has its own JMX Agent and some MBeans. When i deploy and launch the application in WebLogic, i am able to connect to the JMX agent via JConsole with the RMI url.
    But when i get into the Weblogic console, i can not see any JMX consoles! So, basically i am trying to see if there is any JConsole equivalent stuff in Weblogic and how to enable it.
    How can i enable the JMX console in Weblogic ?
    Edited by: SureshKrishna on Jun 19, 2009 10:38 AM

    I suggest also this
    http://www.performanceengineer.com/blog/monitoring-weblogic-using-jmx/
    To enable JXM you should add these in the startup script of the server:
    -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
    then you can access from Jconsole putting this URL in :
    service:jmx:rmi:///jndi/rmi://127.0.0.1:8888/jmxrmi
    Edited by: user3873926 on 19-giu-2009 11.53

  • How to Enable Remote services using the GPO for the Client Machines

    How to enable remote Access services on Client machines using the Group Policy. After enable how to access with out switching the users  remote as administrator

    Hi,
    If you use windows server 2003, we can refer to the following link to enable remote access services on Client machines using the Group Policy:
    Enable or disable Remote Desktop
    http://technet.microsoft.com/en-us/library/cc727977(v=WS.10).aspx
    If you use windows server 2008 and later version, we can refer to the following link to enable remote access services on Client machines using the Group Policy:
    How to Enable or Disable Remote Desktop via Group Policy Windows 2008
    http://social.technet.microsoft.com/wiki/contents/articles/4980.how-to-enable-or-disable-remote-desktop-via-group-policy-windows-2008.aspx
    After you enable
    Allow users to connect remotely using Remote Desktop Services policy setting, users who are members of the Remote Desktop Users group on the target computer can connect remotely to the target computer by using Remote Desktop Services.
    So if you want users to access computer remotely, you need add users as members of the Remote Desktop Users group on the target computer.
    About how to add users to the Remote Desktop Users group, please refer to the following link:
    Configure the Remote Desktop Users Group
    http://technet.microsoft.com/en-us/library/cc743161.aspx
    Best Regards,
    Erin

  • PCR - RPTIME00 - TM00 - how to find of exceeding of the working day

    Hello,
    I'm new in RPTIME00 I need to write a PCR - schema ZM00 (TM00) that find of exceeding of the working day and generate wage type 1506 for cluster B2?
    For example employee works:
    MO: DWS=06:00-14:00
    TU: DWS=06:00-14:00 but TI2011=04:00-14:00
    The point is that I must generate wage type only for time par 04:00-06:00 without generate of WT for overtime (M)
    I though that I need generate WT from PCR with ADDZLS1506 for example... but in this case I need to find exceeding of the working day
    Any ideas?
    I tried with this:
    APD1      *   ****           HRS=D0061
    APD1      *   ****           HRS?S
    APD1      *   ****  >        GCY APD2
    APD2      *   ****           OUTWPTIMER
    APD2      *   ****  1        HRS=SNTB  
    APD2      *   ****  1        HRS?PBEG
    APD2      *   ****  1 >      HRS=PNUM  
    APD2      *   ****  1 >      HRS?CTEPOL
    APD2      *   ****  1 > >    HRS=PNUM                    
    APD2      *   ****  1 > >    HRS?0
    APD2      *   ****  1 > > >  ADDZLS1506
    APD2      *   ****  1 > > >  COLOP*
    Thanks a lof for help.
    BR,
    M
    Edited by: mn-sdf on Jul 6, 2011 10:59 AM
    Edited by: mn-sdf on Jul 6, 2011 11:20 AM

    Thanks for answer but I don't need generate overtime beyond the planned working hours in the end of month. I have WT in PY for additional pay for "exceeding of the working day" (this is not overtime but ... salary supplement? My english is not good enough, sorry).
    I don't need approval for overtime (via 2007 and GOT...) which give me "M" pair type for this case (WT1506). I don't need them. Opposite this I need to find:
    previous day was free or not?
    when was a free day, I don't have to generate 1506
    when is a working day, I have to generate 1506
    My PCR generate WT1506 correctly but on every day where I have start hour (2011) before start working time from DWS.
    Maybe the point is how to find the previous day was free or not?
    Do you know how to do it?
    Thanks a lot!
    BR,
    MN
    Edited by: mn-sdf on Jul 6, 2011 12:41 PM

Maybe you are looking for