I want to call a method on every 5th second, I used a timer, but I don't know how to use it properly.
I have a method in one CountryDTO class as below.
public MoviesDTO getMovieDTOByName(String movieName) {
Session session = factory.openSession();
String hql = "FROM MoviesDTO WHERE name=:nm";
Query query = session.createQuery(hql);
query.setParameter("nm", movieName);
return (MoviesDTO) query.uniqueResult();
}
And I call it from the main method.as below:
public static void main(String[] args) {
Timer timer = new Timer();
CountryDAO countryDAO = new CountryDAO();
timer.schedule(countryDAO.getMovieDTOByName("Rabgo"), 5000);
}
But, I'm getting this below exception:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method schedule(TimerTask, long) in the type Timer is not applicable for the arguments (MoviesDTO, int)