Class InterruptUtil

  • All Implemented Interfaces:
    ContextAware

    public class InterruptUtil
    extends ContextAwareBase
    Allows masking of interrupt flag if previously the flag is already set. Does nothing otherwise. Typical use:
     InterruptUtil interruptUtil = new InterruptUtil(context);
     
     try {
       interruptUtil.maskInterruptFlag();
       someOtherThread.join(delay); 
     } catch(InterruptedException e) {
       // reachable only if join does not succeed within delay.
       // Without the maskInterruptFlag() call, the join() would have returned immediately
       // had the current thread been interrupted previously, i.e. before entering the above block    
     } finally {
       interruptUtil.unmaskInterruptFlag();
     }
     
    Since:
    1.2.2
    • Constructor Detail

      • InterruptUtil

        public InterruptUtil​(Context context)
    • Method Detail

      • maskInterruptFlag

        public void maskInterruptFlag()
      • unmaskInterruptFlag

        public void unmaskInterruptFlag()