Why do you put your artist service in the Runnable class? You should separate the ScheduledExecutorService as a Singleton, not a runnable class variable.
Recall that this ScheduledExecutorService is a container of threads, so when you encode this
this.ses = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
it will create many threads based on the size value at the same time when you put this code
this.ses.scheduleAtFixedRate(this, 0, 1, TimeUnit.SECONDS);
ScheduledExecutorService will randomly select a thread that is idle to run this class every 1 second until it finishes. if you put sleep in the run method, which goes over to the scheduled thread more than the value of the time period, it will not create another thread until the end of the 1st thread. Therefore, if you want multiple threads to run this Poller at the same time, create multiple instances of Poller and pass them to the ScheduledExecutorService
CORE_POOL_SIZE its not redundant for me, its useful to be a constant whose value is taken from the configuration file.
Should it be static? it depends on what you need. if you intend to create multiple instances of Poller then u should not
source share