For running the process at scheduled time, you can use any of the expression (unix cron expression or fixed delay/rate) with spring framework's Scheduled annotation.
public class DemoScheduleCron
{
@Scheduled(cron="*/10 * * * * ?")
//@Scheduled(fixedDelay = 10000)
//@Scheduled(fixedRate = 10000)
public void method1()
{
System.out.println("This method executs for every 10 seconds");
}
}
To implement grabbing contacts from Gmail api, you can use spring Quartz / scheduler which is explained here.
Small snippet of configuring concurrency from above docs:
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="5" />
<property name="maxPoolSize" value="10" />
<property name="queueCapacity" value="25" />
</bean>
<bean id="taskExecutorExample" class="TaskExecutorExample">
<constructor-arg ref="taskExecutor" />
</bean>