newSingleThreadExecutor

Need to optimize the source code about thread;

  • sometimes shutdown, sometimes did not

  • no need to use (create) many threads in the loop

ExecutorService executor = Executors.newSingleThreadExecutor();
        try {

            executor.execute(() -> {

                // If you want to send messages to this application instance or
                // manage this apps subscriptions on the server side, send the
                // Instance ID token to your app server.

                // refresh token
                FirebaseTokenSender.refreshTokenToJfw(
                        getApplicationContext(),
                        token);

            });

        } catch (Exception e) {
            logger.error("{}", e.getMessage());
        } finally {
            executor.shutdown(); // <== some function do not call shutdonw ?
        }

Last updated