Interrupting running Future

My code runs on Java 5.
The callables I submit to a given ExecutorService are pure-computational, meaning: no calls to "low-level blocking methods".
I'd like these computations to be cancellable in a ASAP fashion: that means I'll sometimes call cancel(true) of the Future instance.
If I understand correctly, this will set the interruption status of the thread executing the given Future to true. Now my question is: how can my code distinguish between
a) an interruption request triggered by a cancel(true) on the Future
b) an interruption request triggered by a shutdownNow of the pool
I would like quick cancellation (through interruption), but quick and correct shutdown of the pool is important as well (meaning: I'll likely use shutdownNow() in some circumstances).
Reading stuff like the following make me kind of nervous:
http://forum.java.sun.com/thread.jspa?threadID=775640&start=20&tstart=0
I hope some of the fixes are sheduled for a backport to Java 5?

My original question could have been more clear:
"Should I always propagate the interruption status from the Callable/Runnable to the executor?"
Looking some more at the TPE source, I guess the answer is:
"Not when running on Java 5.0, until the relevant fixes from 6.0 are backported"
So:
1) In my computational loop I inspect isInterrupted()
2) Upon interruption, I exit the loop
3) Before returning from run(), I clear the interruption status
If the current thread interruption status was set because of pool shutdown, the current worker thread will exit anyway (since getTask() will return null)
Message was edited by:
Pakka-Pakka

Similar Messages

  • 2851 Router VPN - stack for level DMA/Timer Interrupt running low 36/9000

    I have a site to site VPN. On my hub router I am seeing the following message EVERY minute in the log!
    %sys-6-stacklow: stack for level DMA/Timer Interrupt running low, 36/9000
    I have been trying to figure out what the DMA/Timer Interrupt is and what is causing it to run low.
    If I run the "show stacks" command I can see:
    <output omitted>
    Interrupt level stacks:
    Level     Called     Unused/Size     Name
    2      1578216246     36/9000     DMA/Timer Interrupt
    I am also occasionaly seeing the following
    %crypto--4-pkt_replay_error:decrypt: replay check failed connection id=7 sequence number=16171319
    I don't know if they are related or not, but I need to find out what is causing the DMA/timer interrupt messages.
    Thanks.

    It just rebooted
    This router it just stands in front of a few servers and applies NAT.
    So far this had happened a few times but since morning it rebooted already 3 times.
    The Sagem ADSL router at my house has longer uptime. wtf!?!?
    cisco>show stacks
    Minimum process stacks:
    Free/Size   Name
    5396/6000   Inspect Init Msg
    5368/6000   SPAN Subsystem
    58920/60000  EEM Auto Registration Proc
    4772/6000   Auto Upgrade Startup Process
    5164/6000   DIB error message
    5396/6000   SASL MAIN
    4968/6000   LICENSE AGENT DEFAULT
    5368/12000  Init
    4216/6000   Update prst
    4384/6000   VPN_HW_MIB_CREATION
    5188/6000   RADIUS INITCONFIG
    2124/3000   Rom Random Update Process
    5316/6000   URPF stats
    Interrupt level stacks:
    Level    Called Unused/Size  Name
      1      319293   6284/9000  Network interfaces
      2      716358   8548/9000  DMA/Timer Interrupt
      3           1   8388/9000  PA Management Int Handler
      4         115   8612/9000  Console Uart
      5           0   9000/9000  External Interrupt
    Interrupt level stacks:
    Level    Called Unused/Size  Name
      7       72787   8564/9000  NMI Interrupt Handler
    Spurious interrupts: 3
    System was restarted by bus error at PC 0x4183BC0C, address 0xC3D1CB7 at 10:51:53 UTC Tue Apr 23 2013
    2800 Software (C2800NM-ADVSECURITYK9-M), Version 12.4(24)T, RELEASE SOFTWARE (fc1)
    Technical Support: http://www.cisco.com/techsupport
    Compiled Wed 25-Feb-09 17:55 by prod_rel_team
    Image text-base: 0x40016C60, data-base: 0x42B47360
    Stack trace from system failure:
    FP: 0x4759C678, RA: 0x4183BC0C
    FP: 0x4759C6D0, RA: 0x41836D18
    FP: 0x4759C708, RA: 0x4164D7E0
    FP: 0x4759C768, RA: 0x41650314
    FP: 0x4759C7E8, RA: 0x41650C68

  • Gaming: How Did They Design Crysis and Maxed It to Run Future Hardware?

    Hi. If anyone has experience creating photorealistic games, how did Crytek design Crysis I to be maxed out for future hardware. What hardware were they using in the first place to run Crysis at max in their offices when it was developed if the hardware didn't exist yet? If they used a system with multiple systems on working in parallel, couldn't consumers copy that system to add to their existing ones (or pool systems with friends just run it at max while waiting for the hardware to do so. But so far at maximum resolution, 2000+ by 2000+, hardware today still struggles with it.). This question is also for Crysis 2. Thanks in advance.
    Gbu

    Hi. Interesting. They didn't have any special game farm parallel rig of some sort? When they tested it in it's maximum 2000+ x 2000+ resolution at very high settings, they were actually playing and testing it at slide show framerates of 1 or 2 fps in their offices then? That's a pain to develop.

  • How to interrupt running subvi with global variation

    Hi,all
       I want to use global variation STOP to interrupt the running VI at anytime, but the subVI must be running until executing the WHILE. I knew when one action is  operated in the EVENT case, the other action will not be iperated. My question is how to solve the problem without  POP subVI and the DATA transmitted to MAIN panel. Give me a suggestion, THKS!
      Lioncsu  
    Attachments:
    Main VI.jpg ‏43 KB
    Sub VI.jpg ‏41 KB

    Hi Lioncsu,
          In Main, when a Start event occurs, the Value of Stop (False?) is immediately written to the Global (once), and SubVI starts running.  The Start event case won't complete - or write another value to the Global - until the SubVI is done.  I haven't run this, but I think pressing Stop may cause the SubVI to run (again) - for one iteration! 
    Attached is a simple VI which uses two loops - one to handle GUI events (the buttons) and one to start a while loop.  Maybe you can replace the while-loop with your SubVI?
    Hope it helps!
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    Notifiers.vi ‏51 KB

  • How to interrupt running PS batch or script?

    Is there any shortcut in Photoshop or Bridge to stop running script or batch? I tried the usual suspects like Esc, Ctrl-C, Ctrl-Break and none worked. I am running Dr. Brown Services and by mistake I let it process 850 photographs instead of 34... The script has finished, but I would like to know for next time...
    Thanks!

    you could try to kill the whole application by pressing Ctrl+Alt+Delete and end the task from the Task Manager

  • Why i cannot run future depreciations at present?

    I have capitalized an asset on 30th december 2008 and the next depreciation for this asset is in jan 2009. its using straight line method.
    however when i tried to run a depreciation on 2nd jan 2009 for the period 1 and financial year 2009, the system says could not find data agrees with the selection made.
    does this mean i have to wait till end of january to post the first depreciation? why cant i run the depreciation for jan 2009 in 2nd jan itself?

    There are 2 things to look to:
    Open the new fiscal year: AJRW - Fiscal Year Change
    The year 2007 should be close see tc OAAQ - Entire Company Code  when not closed run AJAB - Execute
    see for more infromation about the closing https://www.sdn.sap.com/irj/scn/wiki?path=/display/erpfi/asset+accounting

  • 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. ;)

  • Dma interrupt transfer modes in 6602

    I am using four simultaneous counters of a 6602 in continuous buffer modes
    using traditional DAQ. Gates used are PFI38 PFI 26 PFI 18 PFI 10.
    When I use set DAQ Device Information.vi to specify the "data transfer
    mode for GPCTR # " either in DMA (3 of them) or interruption mode ( one of
    them), I am not sure which # to use for the GPCTR #.
    In other words, must I specify GPCTR0, 3, 5 in DMA and GPCTR7 in interrupt?
    Otherwise stated, the simple fact that I use predefined PFI would associate
    the GPCTR concerned or, else, are these GPCTR defined as GPCTR0, 1, 2, and 3
    in the order I open their configurations in my Labview program.
    There is no clear definition of what GPCTR # actually mean in the Labview
    references.
    I have the feeling that some counters generating 15000 counts/sec do not use
    DMA but interrupt transfer modes instead.
    Gérard

    GPCTR# is the general purpose counter resource you are using, there are eight 32-bit counters on the 6602 card.  Unfortunately there are only 3DMA channels which means that if you plan on 4 very high speed buffered counting acquisitions then you could have some trouble since interrupts run much slower than the DMA channels.  I have had no problem using a mix of interrupts and DMA channels for continuously buffered counting with 4-8 counters at a time but the collection rate was only a few KHz faster than this the buffering using interrupts can not keep up an will overrun causing a "buffer overrun" error.  If you really need many highspeed buffer counters running simultaneously you could try using 2 cards but this seems costly (RTSI cable will allow multi-card synchronization).
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • OIM 11g - PeopleSoft connector - Future Dated Recon Events

    Hi OIM Experts,
    I am having a problem, processing the future dated events using OIM peoplesoft connector.
    All the current dated, events are getting linked and processed.
    The future dated events in OIM are in deferred state as expected. But after running the "Run Future Dated Reconciliation Events " , the event is not linked to any user, but state changes to data received.
    The user exists in OIM.
    Any ideas on how to resolve this.
    Regards
    Vicky

    Hi Suren,
    1311 - Cause: Status of the batch is not 'Completed'.
    1311 - Event id, when i try to Re-Evaluate event.
    Regards
    Vicky
    Edited by: vicky on Jan 27, 2011 6:27 PM

  • 100% CPU usage after starting/joining a call

    This problem has been persisting for a few months now, and I haven't found a fix. Sometimes when I would start or join a call, the first thread of my i7 would shoot up to 100% usage (Monitored with MSI Afterburner). I originally thought it was because I had an older version of Skype, but I updated to the latest version and still had the issue. To get the usage to go down, I either have to restart the laptop or put it into sleep mode. When I checked the task manager, Skype was only using 0%-2% of my CPU, but System and System Interrupts run at higher usage (6%-7% each). I am running Windows 8.1 on a laptop with the desktop version of Skype. Please note that this also does not happen every time, just on some occasions.
    EDIT: It eventually happens, but not always right away.

    Yes, you can use NI-DAQmx with Visual C++ and with Mesurement Studio 7 or later you also have Microsoft Visual C++ class libraries for NI-DAQmx.
    If you are now developing a application I would advice to move to DAQmx since this the Traditional libraries are nolonger activly developed, we will only be adding new features and hardware to NI-DAQmx, thus for future support of the application it's better to use NI-DAQmx then Traditional NI-DAQ.
    For more information on NI-DAQmx see:
    http://zone.ni.com/devzone/conceptd.nsf/webmain/ee47b125bb9e053686256fbc0014c384?OpenDocument
    Met vriendelijke groet / Kind regards,
    Karsten
    Applications Engineer
    National Instruments

  • Process terminates in process chain

    Hi ,
    I do have 7 Meta Chains running under one of the Process parallely in BI 7.0. Unfortunately once in a while some of the process are terminating. Its start at the same time as all other of the process, but it does not executes the chain and turns red.
    I don't even get a Process Monitor on that particular process nor a error message. i do can find the two clock symbols on that particular chain the LAST_SAVED & LAST_ACTIVATED. But the process chain does not run future.
    If i run that particular process chain manually again it works properly.
    Can you help me out, to run the process automatically .
    Thanks in advance
    Raju

    Hi Akula,
    When you Schedule a Process chain the Process will be ASSIGNED TO A WORKPROCESS OF aN Application server.
    If there is no workprocess is avaliable in the Application server. the Process will be Terminated.
    As you are scheduling Process chains there may be a Problem with Avaliability of work Processes.Check in sm50 for the no of application servers avaliable and check whether the work Processes are avaliable for each Application servers if you have more than one.
    Try to avoid scheduling the Chains at the sametime.
    hope it helps.
    Thanks,
    -Vijay

  • Multi user catalog and how to make it - use a checked out system

    Lots of people want or need a Multi user ability in lightroom here is one way to achieve multi-user catalogs by using a check-in check-out system.
    The Catalog would open normally upon a second user opening LR would then ask to switch to multi-user mode.
    Once in multi user mode lightroom would lock-out images, collections, or folders by a checked-out for editing system.
    By checking-out images, collections, or folders: files would be unavailable to other users until edits are saved, and the images, collections, or folders are checked-in.
    This check-in check-out system would need a global check-in feature in case someone forgot to check in an image, collection, or folders (global check-in could be admin level). Word documents, CAD files, etc, use a similar lock-out/read only system for the files. Since, we wouldn't want to bloat the files with programing to lock out the files, this would have to be added to the catalog and managed by the catalog.
    My system
    Vista Ultimate 32bit SP1
    AMD 64X2 duel core 6000+ 3.2Ghz
    6GB 666mhz Ram PAE force enabled
    NVIDIA Gforce 7600 256MB video card (1.75GB total with system shared ram)
    primary hard drive 500GB
    Hard drive 2 400GB (system and photoshop paging files and lightroom catalog drive)
    Hdrive 3 1TB (primary image storage)
    user control turned off
    system graphics set to performance
    Duel display
    LR 2.0
    PS extended CS3

    Your thread pool is a pool and probably keeps
    the thread alive even though the thread has nothing
    after a minute toi execute - you'll have to call its
    shutdown() methodThanks Oxe...
    I googled that (easy when you know what the answer is) and yes the ScheduledThreadPool retains threads for re-use, so you have to check that all threads are done and then shutdown() the scheduler... like this:     while (!future.isDone()) {
              try { Thread.sleep(10); } catch(InterruptedException e) {}
         scheduler.shutdown();
    ... here is the complete working class:
    import java.util.concurrent.ScheduledExecutorService;
    import java.util.concurrent.Executors;
    import java.util.concurrent.ScheduledFuture;
    import static java.util.concurrent.TimeUnit.*;
    import java.awt.Toolkit;
    class BeeperControl {
         private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
         public void beepForAMinute() {
              final Toolkit tk = Toolkit.getDefaultToolkit();
              final Runnable beeper = new Runnable() {
                   public void run() {
                        tk.beep();
                        System.out.println("beep");
              final ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(beeper, 250, 250, MILLISECONDS);
              scheduler.schedule(
                   new Runnable() {
                        public void run(){
                             future.cancel(true);
                   }, 3, SECONDS
              while (!future.isDone()) {
                   try { Thread.sleep(10); } catch(InterruptedException e) {}
              scheduler.shutdown();
         public static void main(String[] args)
              BeeperControl bc = new BeeperControl();
              bc.beepForAMinute();
    }Thanx again. Keith.

  • Installing Oracle VDI 3.3 into a zone on Solaris x86

    Hi everyone,
    I'm trying to install Oracle VDI into a zone on an Oracle Solaris Express x86 machine. When I unzip the installer and run ./vda-install in the top dir I get this error:
    Oracle VDI 3.3 Installation
    + Installing Oracle VDI Core...
    + Installing Oracle VDI Center Agent...
    + Installing MySQL Database...
    + Installing Oracle VDI Web server...
    + Installing Oracle VDI Manager...
    + Installing RDP Broker...
    + Installing Sun Ray Client...
    + Installing Java Runtime Environment...
    + Installing Sun Ray Server...
    Error: There was a problem installing Sun Ray Software 5
    Check '/var/sadm/install/logs/vda-install.2011_08_26_19:19:04.log' for details.
    Error: There was a problem installing Sun Ray Software 5
    Check '/var/sadm/install/logs/vda-install.2011_08_26_19:19:04.log' for details.
    It seems that I cannot install Sun Ray Server into a non-global zone. Well that's fine by me provided I don't actually need it.
    And her's my question: what of the above do I actually need?
    Günther

    I guess, it's clear that you need a valid support contract for your Hardware, otherwise your in troubles. A not so bad article about that you kind find at http://www.ypass.net/blog/2010/04/solaris-licensing-changes-the-real-story/
    4.) When you purchase hardware, you receive an addendum to the entitlement that grants that piece of hardware perpetual, non-transferable license and entitlement to Solaris.
    and additional ...
    Sun Servers with a Support Contract
    - For people running Solaris on Sun hardware with a Sun hardware support contract, your support contract grants you rights to run future versions of Solaris.

  • ThreadPoolExecutor- Thread termination

    I created a thread pool executor and submitted some callable tasks to thread pool and waiting on future object in the method futureobject.get(timeout, TimeUnit.SECONDS).
    Once it is timed out i am catching the TimeoutException and cancelling the task through future.cancel(ture),
    But it is just interrupting the thread and not cancelling the task if the task has already started executing.
    Is there any way to stop the future Object task after a certain time out irrespective of its current state?
    I want to terminate the thread execution and make the thread pick another task once if it is timed out.
    One way is to interrupt the thread which is handling the future object task and then stop the thread.
    Is there any other way that I can cancel a future Object task directly without dealing with the thread handling this future object task.
    Can you throw a light on this. Any idea would be helpful...!!
    Thanks in advance.

    Thanks Peter for your reply.
    But the problem is the thread is not like executing in a while loop to test every time whether it is interrupted or not by future.cancel(ture).
    As my callable task is calling internally more methods which are call some more methods of other classes in this i cant put every where this logic to check whether thread is interrupted or not.
    Even i have done that my concern is what if thread is executing a method long time because of some blocking problem. i need to wait the control comes back after method to check whether thread is interrupted or not. which is not desired..
    let me put in an example.
    public Object call(){
    new ArrayList list=SampleClass1Object.readData();
    // check whether thread is interrupt by future.cancel() method
    Object ob= SampleClass2Object.display(list);
    return ob;
    If i fix time in future.get(timeout,TimeUnit). when the time out is happend the thread executing the method readData() it wont reflect immediately once this readData() method is completed then only it will check whether the thread is interrupted or not. This what is happening right now in my case.

  • Graph applet

    hello,
    i wish to draw a line graph in a certain region(ex. rectangle),even when exceeds the dimentions of the rectangle i want to display the current plot...
    for ex. http://java.sun.com/products/java-media/2D/samples/java2demo/Java2Demo.html
    in Arcs_Curves one can see a line plot at rightbottom ,shifting the curve to left,i need the same logic ,ofcourse i have the running curve..
    just i need the logic how the curve is moving to left.
    any suggestons are accepted...a few lines of code is too good...
    thank you,
    bhaskar..

    thanks for the comments,but i mentioned i have the graph,just i need to fit in a certain area...
    here i am sending an example of my code...
    import java.awt.*;
    import java.awt.Button;
    import java.awt.event.*;
    public class MyApplet extends java.applet.Applet implements ActionListener, Runnable {
    int xSPos,ySPos,xOrig,yOrig,width,height;
    private Thread run = null;
    private boolean running;
    private Image bufferImage;
    private Graphics bufferGraphics;
    Button start;
    public void init() {
    setBackground(Color.white);
    setSize(450,300);
    start = new Button("Start");
    add(start);
    start.addActionListener(this);
    public void actionPerformed(ActionEvent ae) {
    try {       
    System.err.println( "run is: "+run );
    if( run != null ) {
    run.interrupt();
    run.join();
    run = new Thread(this);
    run.start();
    } catch( InterruptedException ie ) {
    repaint();
    public void paint(Graphics g) {
    update(g);
    public void update(Graphics g) {
         if(bufferImage != null)
              g.drawImage(bufferImage,0,0,this);
    public void run() {
    running = false;
    int W = 0,H = 0;
         if(bufferGraphics == null) {
              Dimension d = getSize();
              W = d.width;
              H = d.height;
              bufferImage = createImage(W,H);
              bufferGraphics = bufferImage.getGraphics();
    xSPos = 50;
    ySPos = 80;
    width = 200;
    height = 100;
    xOrig = xSPos;
    yOrig = ySPos+height;
    int xLocP = xOrig;
    int yLocP = yOrig;
    int xMax = 150;
    int yMax = 90;
    for(int i=0; i<=500; i++) {
    int xLoc = xOrig;
    int yLoc = yOrig;
    xLoc = xLoc+Math.round(width*i/xMax);
    yLoc = yLoc-Math.round(height*i/yMax);
    bufferGraphics.setColor(Color.black);
    bufferGraphics.drawRect(xSPos,ySPos,width,height);
    bufferGraphics.setColor(Color.blue);
    bufferGraphics.drawLine(xLocP, yLocP, xLoc, yLoc);
    try {
    Thread.sleep(350);
    catch(Exception ex) {
              repaint();
    xLocP = xLoc;
    yLocP = yLoc;
    run = null;
         running = false;
    bufferGraphics = null;
         //repaint();
    from this output when the line crosses the dimentions of rectangle,the old points should delete so that there will be space to draw for new values...got my point...
    once more thankyou...

Maybe you are looking for

  • Ides installation error during "perform post-load activities" ORA-00942:

    Dear Guru's I am having problem in ides ERP 2005 SR1 installation .with oracle 10g on windows 2003. Currently i am facing problem at "perform post-load activities" Below is the logs from sapinst_dev.log:- TRACE      [iaxohsqlx.hpp:1043]            CO

  • Safari 6 bug (Can't download software files) - file not in download window

    Dear Everybody, I insatlled Safari 6 and also afterwards ML, everything works fine on my macbook air but on my 2009 (early) iMac safari 6 has a severe problem. When I download software files such as a adove flash player dmg file, The file (link) load

  • Desktop folders + icons moving after startup

    Some (but not all) folders and icons on my desktop change position each time I start-up. It is always the same folders & icons and they always move to top right of my screen. How can I stop this? It make no difference I use sort by > align to grid or

  • Scroll Bar Thumbnails gone

    I have Adobe Acrobat Pro 9 Extended. In Pro 8 I was able to view each page as a thumbnail as I scrolled using the scroll bar button. The thumbnail would appear immediately beside the scroll button on the right of the screen. I can't seem to get Acrob

  • CS6 Beta TIMED OUT - Working with Techs for Resolve

    I've been using CS6 Beta for many months. The other day, I could NOT get passed the "Continue Trial" dialog. Thus, I am unable to use the app and report bugs to Adobe. I'm working with Adobe techs to see if we can identify the problem and find a comm