Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7409997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:09:55+00:00 2026-05-29T06:09:55+00:00

I want to call parsePage() method every 2 hours, the method will process the

  • 0

I want to call parsePage() method every 2 hours, the method will process the page and update the information in database. I want to put this in a Tomcat server and my code looks like this right now:

TimerTask parserTimerTask = new TimerTask() {
    @Override
    public void run() {
        MyParser.parsePage();
    }
};

Timer parserTimer = new Timer();
parserTimer.scheduleAtFixedRate(parserTimerTask, 0, PERIOD);

I put this in class(that load on start up)’s init() method.

Am I doing this correctly? Or is there better way to do this task?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:09:55+00:00Added an answer on May 29, 2026 at 6:09 am

    Your approach should work.

    You’ll obviously also need to create a Timer and pass the TimerTask to the appropriate schedule method in order to kick off the execution of the TimerTask in a repeated manner, something like:

    Timer timer=new Timer(true);
    timer.schedule(myTimerTask, 0, 2*3600*1000L);
    

    In more sophisticated environments, you might want to look at using something like the Quartz Scheduler. This will give you things like better logging, redundancy failover, more sophisticated schedules, transaction control etc. But all this probably isn’t necessary for a simple use case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a process via a python program, however, this process need
I want to call my .NET code from unmanaged C++. My process entrypoint is
I want to call a method on an object which I get through [self
I want to call a generic method that constrains the input type T to
I want to call a method confirmExit() when the red close button of the
I want call OnClick function on page load with out user clicking. Can we
Hi I want call f('append','more','arguments',a=1,b=2) but append is a method(function) of pyquery module so
I have a UIButton, and I want call a method when I click it.
I m developing website. i want call one ashx file which return all process
I want to call two functions automatically when the page loads. How to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.