void stopAfter ( int remainingScans ) { Thread thread ; synchronized ( this . monitor ) { thread = this . watchThread ; if ( thread != null ) { this . remainingScans . set ( remainingScans ) ; if ( remainingScans <= 0 ) { thread . interrupt ( ) ; } } this . watchThread = null ; } if ( thread != null && Thread . currentThread ( ) != thread ) { try { thread . join ( ) ; } catch ( InterruptedException ex ) { Thread . currentThread ( ) . interrupt ( ) ; } } }
Stop monitoring the source folders .