Will the actor system execute scheduled tasks when it gets termintaed


I have went through the akka documentation where it mentioned the below statement.

All scheduled task will be executed when theActorSystemis terminated, i.e. the task may execute before its timeout.

Below is the code I used to test this,

private static List<Cancellable> cancellableList = new ArrayList<>();

 public static void main(String args[]) throws Exception {
    system = ActorSystem.create("ReactorCluster");
    actorA = system.actorOf(Props.create(ActorA.class), "actorA");
    Cancellable c = getSystem()
        .scheduleOnce(Duration.ofSeconds(10), actorA, "hi", getSystem().dispatcher(), ActorRef.noSender());
    Cancellable c2 = getSystem()
        .scheduleOnce(Duration.ofSeconds(12), actorA, "hello", getSystem().dispatcher(), ActorRef.noSender());

Below is createReceive implementation for ActorA

  public Receive createReceive() {
    return receiveBuilder()
      .matchEquals("hi", h->{
      .matchEquals("hello", hello->{

But it is not printing hi and hello message in the console. Kindly guide me on this !!

The timer is shutdown after all the actors are stopped, which means your actor cannot verify it by receiving a message, the actor has already stopped.

Note that always running timer tasks on shutdown is changing for the upcoming Akka 2.6, see issue #16495 for details.