public static void main ( String [ ] args ) { SimonManager . callback ( ) . addCallback ( new CallbackSkeleton ( ) { @ Override public void onStopwatchStart ( Split split ) { System . out . println ( "\nStopwatch " + split . getStopwatch ( ) . getName ( ) + " has just been started." ) ; } @ Override public void onStopwatchStop ( Split split , StopwatchSample sample ) { System . out . println ( "Stopwatch " + split . getStopwatch ( ) . getName ( ) + " has just been stopped (" + SimonUtils . presentNanoTime ( split . runningFor ( ) ) + ")." ) ; } } ) ; Stopwatch sw = SimonManager . getStopwatch ( SimonUtils . generateName ( ) ) ; sw . start ( ) . stop ( ) ; Split split = sw . start ( ) ; //noinspection StatementWithEmptyBody for ( int i = 0 ; i < 1000000 ; i ++ ) { // what does JVM do with empty loop? :-))) } split . stop ( ) ; sw . start ( ) . stop ( ) ; System . out . println ( "\nAdditional stop() does nothing, Split state is preserved." ) ; split . stop ( ) ; System . out . println ( "split = " + split ) ; }
Entry point to the Callback Example .