简体   繁体   中英

scheduleAtFixedRate() is being called twice

Logs:

[pool-1-thread-1] TRACE apns.ApnsPushConnection - Enter Method queryFeedbackService params [pool-3-thread-1] TRACE apns.ApnsPushConnection - Enter Method queryFeedbackService params [pool-1-thread-1] TRACE apns.ApnsPushConnection - Return Method queryFeedbackService
[pool-3-thread-1] TRACE apns.ApnsPushConnection - Return Method queryFeedbackService

//In Singleton class constructor
ScheduledExectorService obj = Executors.newSingleThreadScheduledExecutor();


obj.scheduleAtFixedDelay(new runnable(){

     public void run(){ 
     classObj.queryFeedbackService();
}  
}),20,60,TimeUnit.SECONDS);     



//method called by thread      
public void queryFeedbackService()
{

     code here

}

Indeed there was 2 pools as per answered by Jean.

But in my case here, my project is loaded into Jetty server which was initialized by Spring.

Also inside Jetty server - it was creating container for Spring beans that were getting initialized from service-context.xml file.

So It was getting called twice that leads to the creation of two pools

Thanks you all those who commented and tried solve my issue. Means a lot :)

From the log, you have several several pools running: pool-1 and pool-3 .

You might want to make sure you only initialize one pool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM