Is interrupted status safe? please help.

I have read the section about interrupts in the Java Tutorial and the API documentation about the interrupt() method but I was unable to find the answer to this question.
I have two threads: thread1 and thread2
The run() method for thread1 is:
public void run() {
     while(true) {
          System.out.println("Hello");
          if (Thread.currentThread().isInterrupted()) {
               break;
     System.out.println("Thread 1 ending");
}In each iteration, thread1 checks its interrupted status.
To stop the thread1, the thread2 executes the following:
thread1.interrupt();The methods interrupt() and isInterrupted() both access the interrupted status of thread1. Therefore the interrupted status of thread1 is a shared variable used by two threads. Is there any risk of inconsistency on the interrupted status caused by the concurrent access?
In other words:
I'm worried about the concurrent acces on the interrupted status variable.
Do the interrupt() and isInterrupted() methods take care of the synchronization on the interrupted status variable or should I use some synchronization mechanism?
Thank you very much for the help.

the only thing i'd point out, is that you need to be careful which method you use to test the interrupt status. the isInterrupted() method checks the status and leaves the status alone, whereas the interrupted() method checks the status and then clears it. make sure you are using the version which has the behavior you desire.
other than that, i can't think of any other "idioms". i guess i will mention that generally you want to use wait/notify to coordinate threads ("normal" communication). interrupt should generally only be used be used when you want to stop the progress of a thread (abnormal communication, e.g. due to a problem).

Similar Messages

  • Gigabit interface status faulty please help

    When I do a show interface status on 4500 switch I got a status faulty
    I did never see such thing
    Port- Name-Status-Vlan-Duplex-Speed Type
    Gi2/7-jsh3 faulty 188 full XXBaseSX
    Could you please help?
    Thanks a lot

    this usually indicates the port is faulty (bad; not working; will not work)
    this may have been set via the POST of the device. the internal tests failed and the port was marked FAULTY.
    this could also be the result of a good port simply went bad for some unknown reason.
    try to disable/reEnable the port. will probably still say faulty. (cannot initialize a faulty port)
    try to reset the blade the port is on, or the supervisor if it resides on that.
    do a "show test" (catOS) to see what the POST found when it did its powerOnSelfTests.
    i've seen plenty of FAULTY ports and 99% of the time, the port is simply bad and must be replaced. (usually an ASIC or the likes)

  • Hardrive Icon interrupts normal Startup - Please Help

    Tonight upon starting my macbook, instead of the normal startup process it instead stayed at the gray screen and in place of the Apple symbol and the loading icon, there was a picture of the Macintosh HD with the word "Hardrive" under it. I turned the computer off and restarted, it started normally as it has always done. I've had this laptop for a year and a half and it has not done anything like this, it has in fact been the best computer I've had so far. Please help me, these things make me very uneasy and I worry about fixing them.
    PS: I only really found one post with an almost identical case to mine that was posted back in December. Some theories in that thread included loose hardware inside the laptop, or for whatever reason the computer not knowing where to boot up from. I just got done with a 2 hour trip in the car that had a few bumps along the way - could this have caused the problem? Again, hope to hear an answer soon. Thanks for any help.

    No USB keys, no DVD's connected either?
    I recall the OLD OS 6-9 would have a similar situation when a faulty HDD or Mount issue occurred.
    Try to repair the internal HDD with the DVD, or there should be a way to boot-up with no extensions or startup items.

  • S.M.A.R.T. Status:  Failing, Please Help...

    About a week ago my iMac G5 froze. I had to unplug it from the wall to restart it, and when I did I got the "?" folder meaning it couldn't find a startup disk. I then ran the disk utility from the Tiger install disk and that froze halfway through also. Now the utility says that the drive has reported a fatal hardware error and the S.M.A.R.T. status is failing. I can't do anything with my 6 month old computer, which is no longer covered by warranty. Any help or suggestions would be much appreciated.

    Ouch doesn't sound good, sounds expensive. You can if I'm not mistaken still purchase Apple Care and I thought it was a 1 year warrantee with 90 days phone support. Bob :~)
    PRODUCT WARRANTY
    All Apple hardware products, including clearance and refurbished products, carry a one-year Limited Warranty against defects in materials and workmanship. You may review a copy of the Limited Warranty on new products, including its limitations and exclusions, before you purchase.

  • Posted this query several times but no reply. Please help me out

    Hi all,
    How to know whether a servlet had completely sent its response to the request.
    The problem what i am facing is, I send response to a client's request as a file.
    The byte by byte transfer happens, now if the client interrupts or cancels the operation, the response is not completed.
    At this stage how to know the response status. I am handling all exception, even then I am unable to trap the status.
    Please help me out.
    I have posted this query several times but no convincing reply till now. Hence please help me out.
    If somebody wants to see the code. I'll send it through mail.
    regards
    venkat

    Hi,
    thanks for the reply,
    Please check the code what I have written. The servlet if I execute in Javawebserver2.0 I could trap the exception. If the same servlet is running in weblogic 6.0 I am unable to get the exception.
    Please note that I have maintained counter and all necessary exception handling even then unable to trap the exception.
    //code//
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.security.*;
    public class TestServ extends HttpServlet
    Exception exception;
    public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException, UnavailableException
         int bytesRead=0;
         int count=0;
         byte[] buff=new byte[1];
    OutputStream out=res.getOutputStream ();
    res.setContentType( "application/pdf"); // MIME type for pdf doc
    String fileURL ="http://localhost:7001/soap.pdf";
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    boolean download=false;
         int fsize=0;
         res.setHeader("Content-disposition", "attachment; filename="+"soap.pdf" );
    try
                   URL url=new URL(fileURL);
         bis = new BufferedInputStream(url.openStream());
         fsize=bis.available();
         bos = new BufferedOutputStream(out);
    while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
              try
                        bos.write(bytesRead);
                        count +=bytesRead;
                        bos.flush();
                   }//end of try for while loop
                   catch(StreamCorruptedException ex)
                        System.out.println("Exception ="+ex);
                        setError(ex);
                        break;
                   catch(SocketException e)
                        setError(e);
                        break;
                   catch(Exception e)
                        System.out.println("Exception in while of TestServlet is " +e.getMessage());
                        if(e != null)
                             System.out.println("File not downloaded properly"+e);
                             setError(e);
                             break;
                        }//if ends
                   }//end of catch for while loop
    }//while ends
              Exception eError=getError();
              if(eError!=null)
                   System.out.println("\n\n\n\nFile Not DownLoaded properly\n\n\n\n");
              else if(bytesRead == -1)
              System.out.println("\n\n\n\ndownload \nsuccessful\n\n\n\n");
              else
              System.out.println("\n\n\n\ndownload not successful\n\n\n\n");
    catch(MalformedURLException e)
    System.out.println ( "Exception inside TestServlet is " +e.getMessage());
    catch(IOException e)
    System.out.println ( "IOException inside TestServlet is " +e.getMessage());
         finally
              try
         if (bis != null)
         bis.close();
         if (bos != null)
         {bos.close();}
              catch(Exception e)
                   System.out.println("here ="+e);
    }//doPost ends
    public void setError(Exception e)
         exception=e;
         System.out.println("\n\n\nException occurred is "+e+"\n\n\n");
    public Exception getError()
              return exception;
    }//class ends
    //ends
    regards,
    venakt

  • Very big problem....please help me

    Hai,
    I am in big trouble... that I am developing site in jsp in that i need to print one htmltextarea editor.I am using ephoxlive editor that is third party tool.
    Here I am able to retrive all content from this editor then I need to print this content if it is successfully printed based on that I need to update the print_status column in database...
    Becaz i will allow the user to print only once... based on this column...
    How i can handle the printer status..
    please help...
    -Thiru

    http://forum.java.sun.com/thread.jsp?forum=45&thread=446990&tstart=0&trange=15

  • Assignment of GL a/c  to cocode please help

    Dear SAP GURUS
    please tell me what might be the problem.
    When i am doing the posting in MB1C using 561 i am getting the error.
    'G/L A/c 399999 does not exist in company code XXXX while the company code is assigned to the chart of accounts INT and chart of accounts INT is assigned to the G/L a/c 1000 which is an IDES one.
    please tell me what might be the issue.
    I don't know whether it belongs to MM or FI but i have made to do this in my office.
    please reply my answer as soon as possible.
    I have tried using FS00 and FS01 it is allowing me to save as will as if i click on w. template then it is saying that it is not assigned to field status variant.
    please help me out from this.
    thanks and regards.
    Thanks and Regards

    Dear Kanchi,
    Please check Tcode OMWD, here your plant should be assigned to Field group '0001'.
    Hope this solves your problem.
    Regards,
    Abhee.

  • Currency COnversion Error: RUN_LOGIC:Member LC not exist.......Please help

    Hi All,
    I am trying to run currency conversion and following is my script logic.
    *RUN_PROGRAM CURR_CONVERSION
          CATEGORY  = %CATEGORY_SET% 
          TID_RA = %TIME_SET%
          RATEENTITY = GLOBAL
          CURRENCY = %RPTCURRENCY_SET%
          OTHER = [ENTITY=%P_CC_SET%]
    *ENDRUN_PROGRAM
    I have also tried the following reading from other post
    *RUN_PROGRAM CURR_CONVERSION
          SELECT(%RptCurrency_SET%,"[ID]",RptCurrency,"[CURRENCY_TYPE]='R'")
          CATEGORY  = %CATEGORY_SET% 
          TID_RA = %TIME_SET%
          RATEENTITY = GLOBAL
          CURRENCY = %RptCurrency_SET% 
          OTHER = [ENTITY=%P_CC_SET%]
    *ENDRUN_PROGRAM
    My RPTCURRENCY dimension had following entries
    ID REPORTING CURRENCY_TYPE
    USD Y R
    EUR Y R
    LC       L
    Also my Currency Conversion data package selection is as follows:
    P_CC: ALL
    CATEGORY: ACTUAL
    RPTCURRENCY: ALL
    TIME: 2008.JAN
    Following is the error
    RUN_LOGIC:Member "LC" not exist
    Failed
    Application: PLANNING Package status: ERROR
    Please help.
    Thanks,
    Diksha.

    Hi All,
    My LGX files is as follow
    *RUN_PROGRAM CURR_CONVERSION
    SELECT(,[ID],RptCurrency,[CURRENCY_TYPE]='R' )
    CATEGORY =
    TID_RA =
    RATEENTITY = GLOBAL
    CURRENCY =
    OTHER = [ENTITY=]
    *ENDRUN_PROGRAM
    If I am not wrong it should have substituted vales for variable %RptCurrency_SET% to USD and EUR.
    Please let me know.
    Diksha.
    Edited by: Diksha Chopra on Dec 22, 2010 5:27 AM

  • My MB is always starting up in safe mode... why? What to do to start-up normally? Please help.

    Hi,
    I am frequently having troubles with my MB. Different types of troubles. Couldn't solve a single one yet.
    I have performed reboot MB in safe mode-- hold down the left shift key after the start up tone till the spinning gear appeared.
    Few hours back i performed that, and since then it just starting up in safe mode without holding the any shift key. I have password protected log-in and each time the dialog box shown the safe mode, not the normal boot as it used to be. I restarted so many times, but same result.
    I started-up by holding down the Option key, dialog box showing the same thing "safe mode" and same result.
    I started-up in single user mode, and then typed reboot, then pressed enter/return button, but dialog box shown the same and it started up in safe mode after entering the password.
    While in the safe mode, i have selected the Mac OS X 10.4.11 from the preference pane, then restarted, but all produced the same result, same dialog box showing the safe mode.
    I couldn't take the screen shot of that dialog box that appears before starting up.
    I am currently using the internet while in safe mode, and using ethernet adapter- a AirStream 1100 F25 external modem attached to the USB port. I don't know if that is good for my MB to use internet on the safe mode.
    I used disk utility and verified the disk during the safe mode, i don't know if that is right or wrong to perform that utility in safe mode, but it all appeared as normal. You can see that from the following image.
    Few days back, i performed the disk utility to verify disk while on the normal boot. But the result shown the red marks, please see the following image for details.
    Hardware Overview:
      Model Name:          MacBook
      Model Identifier:          MacBook2,1
      Processor Name:          Intel Core 2 Duo
      Processor Speed:          2 GHz
      Number Of Processors:          1
      Total Number Of Cores:          2
      L2 Cache (per processor):          4 MB
      Memory:          1 GB
      Bus Speed:          667 MHz
      Boot ROM Version:          MB21.00A5.B07
      SMC Version:          1.13f3
      Serial Number:          4*********M
      Sudden Motion Sensor:
      State:          Enabled
    BANK 0/DIMM0:
      Size:          512 MB
      Type:          DDR2 SDRAM
      Speed:          667 MHz
      Status:          OK
    BANK 1/DIMM1:
      Size:          512 MB
      Type:          DDR2 SDRAM
      Speed:          667 MHz
      Status:          OK
    System Power Settings:
      AC Power:
      System Sleep Timer (Minutes):          10
      Disk Sleep Timer (Minutes):          10
      Display Sleep Timer (Minutes):          10
      Automatic Restart On Power Loss:          No
      Wake On AC Change:          No
      Wake On Clamshell Open:          Yes
      Wake On LAN:          Yes
      Display Sleep Uses Dim:          Yes
      Battery Power:
      System Sleep Timer (Minutes):          5
      Disk Sleep Timer (Minutes):          10
      Display Sleep Timer (Minutes):          1
      Wake On AC Change:          No
      Wake On Clamshell Open:          Yes
      Display Sleep Uses Dim:          Yes
      Reduce Brightness:          Yes
    Battery Information:
      Battery Installed:          Yes
      First low level warning:          No
      Full Charge Capacity (mAh):          2745
      Remaining Capacity (mAh):          2745
      Amperage (mA):          133
      Voltage (mV):          12575
      Cycle Count:          507
    AC Charger Information:
      Connected:          Yes
      Charging:          No
    Hardware Configuration:
      UPS Installed:          No
    Intel ICH7-M AHCI:
      Vendor:          Intel
      Product:          ICH7-M AHCI
      Speed:          1.5 Gigabit
      Description:          AHCI Version 1.10 Supported
    TOSHIBA MK1234GSX:
      Capacity:          111.79 GB
      Model:          TOSHIBA MK1234GSX
      Revision:          AH008B
      Serial Number:          Z6M7T4FTT
      Native Command Queuing:          Yes
      Queue Depth:          8
      Removable Media:          No
      Detachable Drive:          No
      BSD Name:          disk0
      OS9 Drivers:          No
      S.M.A.R.T. status:          Verified
      Volumes:
    Macintosh HD:
      Capacity:          111.47 GB
      Available:          24.09 GB
      Writable:          Yes
      File System:          Journaled HFS+
      BSD Name:          disk0s2
      Mount Point:          /
    TOSHIBA MK1234GSX:
      Capacity:          111.79 GB
      Model:          TOSHIBA MK1234GSX
      Revision:          AH008B
      Serial Number:          Z6M7T4FTT
      Native Command Queuing:          Yes
      Queue Depth:          8
      Removable Media:          No
      Detachable Drive:          No
      BSD Name:          disk0
      OS9 Drivers:          No
      S.M.A.R.T. status:          Verified
      Volumes:
    Macintosh HD:
      Capacity:          111.47 GB
      Available:          24.09 GB
      Writable:          Yes
      File System:          Journaled HFS+
      BSD Name:          disk0s2
      Mount Point:          /
    System Software Overview:
      System Version:          Mac OS X 10.4.11 (8S2167)
      Kernel Version:          Darwin 8.11.1
      Boot Volume:          Macintosh HD
    Please help me out. Let me know how to start-up normally. By the way, my superdrive is not detecting DVDs including the OS dvds, but it read and write the CDs. So, It is not possible to reinstall OS early, at least not before the having the back up of the data. Please help me with contingency plan/s or as you think fit.
    Thank you. Look forward to your reply.
    <Personal Information Edited by Host> 

    Maximillianmann,
    depending upon how full “almost full” actually is, that could be the problem.
    You can try this, if you have Mac OS X 10.7 or newer installed, to see if it’s not related to your disk being almost full: boot your MacBook Pro into Recovery mode by holding down a Command key and the R key as it starts up. Once the Mac OS X Utilities menu appears, select Disk Utility. On the left-hand side of the Disk Utility window, select your internal disk’s boot partition (typically called “Macintosh HD”). On the right-hand side, press the Verify Disk button if it’s not greyed out; if it is greyed out, or if it reports that errors were found, press the Repair Disk button. Once the verification/repair is completed, exit Disk Utility and select Restart from the Apple menu to restart in normal mode. Once you hear the startup chime, try booting into Safe mode; does it let you do so now?

  • Status error 0xc00000e9 PLEASE HELP!!!

    Yestarday my laptop (a satellite L450-11W) took a slight fall off my bed onto the floor. I picked it up and all seemed ok until i got this error message:
    Windows has encountered a problem communicating with a device connected to your computer.
    This error can be caused by unplugging a removable storage device such as an external USB drive while the device is in use, or by faulty hardware such as a hard drive or CD-ROM that is failing. Make sure any removable storage is properly connected and then restart your computer. If you continue to recieve this message, contact the hardware manufacturer.
    Status: 0xc00000e9
    Info: An unexpected I/O error has occured
    I press enter to continue and then this comes up after loading the Toshiba logo again:
    Launch startup repair (recommended)
    Start windows normally
    Which ever one i choose the same thing happens, it will take me to a screen saying
    Windows is loading files, it will fill the bar once very quickly before stopping at about a sixth of the way the second time round and will not go any further. It then takes me back to the error screen.
    This is the sqme for all the f8 options such as safe mode that have been suggested in other forums and each has resulted in the exact same thing.
    I had headphones plugged into it at the time which unplugged from the laptop when it fell. Also there was a CD in it at the time which wasn't running but when i took it out it appeared to be faulty.
    Please help as this is starting to worry me now as i have school work due in soon,
    Thanks in advance,
    Danny

    I almost alway go into Window MINI xp. If this successfully loads with out any issues...try using a Wireless mouse and insert the Dongle into each of the USB ports to see if they all work.  And the SD Card Slot...may not function as the drivers are not loaded.
    If all of this is good. And obviously the DVD-Rom drive is working...then we have an issue where the Hard Drive Heads may have come into contact with the Platter and ruined the Sector with the boot data it needs to continue a normal boot cycle. 
    "My comments are my own reality" Consider these in addition to other sources. I only know what I know.
    Dan

  • The status bar is pushed up at about 3/4 of the screen, so I can view onlu firefox at about 1/4, good thing there is a scroll bar, but below the status bar is white display? can u please help me, I want to drag down the status bar so I can have a full vi

    The status bar is pushed up at about 3/4 of the screen, so I can view only Firefox at about 1/4, good thing there is a scroll bar, but below the status bar is white display? can u please help me, I want to drag down the status bar so I can have a full view
    == This happened ==
    Every time Firefox opened

    Your code is absolutely unreadable - even if someone was willing to
    help, it's simply impossible. I do give you a few tips, though: If you
    understand your code (i.e. if it really is YOUR code), you should be
    able to realize that your minimum and maximum never get set (thus they
    are both 0) and your exam 3 is set with the wrong value. SEE where
    those should get set and figure out why they're not. Chances are you
    are doing something to them that makes one 'if' fail or you just
    erroneously assign a wrong variable!

  • I had the Norton ID safe on a toolbar. I got a message saying that toolbar was unsafe. I clicked on yes to remove it. Now I want a new toolbar for it and I cannot find how to do that Please help?

    I had a message come up that my Norton Identity Safe toolbar was corrupting my computer. There were more things than just that in the message. I told them to remove it by my clicking yes. I since have tried to download a new safer toolbar from Norton. I cannot get the toolbar back no matter what I do. I have tried everything. Going on Norton website has not helped. I do what they tell me to and I get nowhere. Please help because there was a lot of information on that and it helped with passwords to different websites that I visited.

    I called Apple Support and they walked me through it. They told me to basically copy and paste my music to the external hard drive. (I think.) Or maybe it was they had me transfer a folder to the EHD. I don't exactally remember it was a few years back. But I tried to plug in the EHD before starting and...nothing. Still says same thing, "locate file."

  • My firefox wont open, I've uninstalled and reinstalled it and it still doesnt work. It wont open so I can't change anything in safe mode. Please help :(

    I used to have at&t internet, dont know what this has to do with it but it's weird that as soon as I switched over to comcast internet my firefox completely stopped working -__- I try to open it and it loads but the page never comes up. Someone please help me, I dont want to lose my bookmarks and passwords..

    Another way to start into Safe Mode is to hold the Shift key when double-clicking the Firefox icon.
    If you have tried to start multiple times, you might have a frozen Firefox process in memory. To terminate that (I'm assuming Windows) open the Task Manager using Ctrl+Shift+Esc, click into the Processes tab, and look for firefox.exe. If you find it, highlight it and click End Process to kill it. Alternately, restarting Windows will clear it.
    Any luck starting in Safe Mode?
    Did you install any software from Comcast?

  • Please help me with EVEN MORE SAFE LOGIN ISSUES.

    This is the screen capture I get when after paying properly for the licenses for F-Secure software in My Safe I get the message in this galleries above screen capture. My subscription was cancelled and that my money was refunded. THIS IS INTERMITTENT. I am really being messed with. Please help me out guys. I tried calling F-Secure tech support and customer support then this is how that went. I first had customer service verify that I made for and paid for the purchase through the Cleverbridge reference numbers. Then after I confirmed that I had paid for the software licenses and had not recieved a refund the agent helped me reset my password for the Safe login multiple times. It was finally on the third try that it worked and I was able to log in and instead of the red letters. It showed that I could download the software. I now go back all the same login details and I can not login and download the software. I get an account canceled message. I really have had it with this situation. Please see the error screen below Thanks Rich. 

    Hi Rich,
    Just to check with you, did you cancel the purchase and requested for a refund? If you did, then that is probably why after the password reset and you try to log in, it says that your subscription is terminated due to cancellation.
    Unless you've purchased another subscription after you made the cancellation. Can you confirm this?

  • My software is STUCK on "Retrieving current session status" What is this and how do I fix it? i am not able to convert any files at all!! Please help!

    My software is STUCK on "Retrieving current session status" What is this and how do I fix it? i am not able to convert any files at all!! Please help!

    Hi JulietaQ,
    In order to help you better.
    Please let me know which application or Service of Adobe you are using. If this is subscription i would request you to log-out and log-in back and let me know if that helps.
    ~Ajlan Huda

Maybe you are looking for