G555
G555

Reputation: 105

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

}

Upvotes: 1

Views: 1549

Answers (2)

G555
G555

Reputation: 105

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 :)

Upvotes: 1

Jean Logeart
Jean Logeart

Reputation: 53819

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.

Upvotes: 0

Related Questions