About Question enthuware.ocpjp.v8.2.1256 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
6a617661
Posts: 2
Joined: Wed Jul 11, 2018 5:18 am
Contact:

About Question enthuware.ocpjp.v8.2.1256 :

Post by 6a617661 »

The sample code does not shutdown the ScheduledExecutorService thus the application will run indefinitely after the beeps finish.

Suggested edit:

Code: Select all

  
  public void beepForAnHour() {
    final ScheduledFuture<?> beeperHandle = scheduler.scheduleAtFixedRate( () -> System.out.println( "beep" ), 10, 10, SECONDS );
    scheduler.schedule( () -> {
      beeperHandle.cancel( true );
      scheduler.shutdown();
    }, 60 * 60, SECONDS );
  }
  

Post Reply

Who is online

Users browsing this forum: mcpunjabi and 45 guests