620 // We should not prevent other consumers from running
621 // concurrently while this consumer blocks on the native
622 // consumer loop. Instead, native code will acquire the
623 // LocalConsumer.class monitor as needed before calling
624 // libdtrace functions.
625 //
626 _consume();
627
628 } catch (Throwable e) {
629 if (exceptionHandler != null) {
630 exceptionHandler.handleException(e);
631 } else {
632 e.printStackTrace();
633 }
634 } finally {
635 synchronized (stopLock) {
636 // Notify listeners while holding stopLock to guarantee
637 // that listeners finish executing consumerStopped()
638 // before the stop() method returns.
639 synchronized (this) {
640 if (state == State.STOPPED || state == state.CLOSED) {
641 //
642 // This consumer was stopped just after calling
643 // go() but before starting (the premature return
644 // case at the top of this work() method). It is
645 // possible to call close() on a consumer that has
646 // been stopped before starting. In that case the
647 // premature return above still takes us here in the
648 // finally clause, and we must not revert the CLOSED
649 // state to STOPPED.
650 //
651 } else {
652 state = State.STOPPED;
653 fireConsumerStopped(new ConsumerEvent(this,
654 System.nanoTime()));
655 }
656 }
657
658 // Notify the stop() method to stop waiting
659 workEnded = true;
660 stopLock.notifyAll();
|
620 // We should not prevent other consumers from running
621 // concurrently while this consumer blocks on the native
622 // consumer loop. Instead, native code will acquire the
623 // LocalConsumer.class monitor as needed before calling
624 // libdtrace functions.
625 //
626 _consume();
627
628 } catch (Throwable e) {
629 if (exceptionHandler != null) {
630 exceptionHandler.handleException(e);
631 } else {
632 e.printStackTrace();
633 }
634 } finally {
635 synchronized (stopLock) {
636 // Notify listeners while holding stopLock to guarantee
637 // that listeners finish executing consumerStopped()
638 // before the stop() method returns.
639 synchronized (this) {
640 if (state == State.STOPPED || state == State.CLOSED) {
641 //
642 // This consumer was stopped just after calling
643 // go() but before starting (the premature return
644 // case at the top of this work() method). It is
645 // possible to call close() on a consumer that has
646 // been stopped before starting. In that case the
647 // premature return above still takes us here in the
648 // finally clause, and we must not revert the CLOSED
649 // state to STOPPED.
650 //
651 } else {
652 state = State.STOPPED;
653 fireConsumerStopped(new ConsumerEvent(this,
654 System.nanoTime()));
655 }
656 }
657
658 // Notify the stop() method to stop waiting
659 workEnded = true;
660 stopLock.notifyAll();
|