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

  • Home
  • SEARCH
  • 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 7828135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:13:09+00:00 2026-06-02T10:13:09+00:00

So I will try to discuss the specifics of my program as generally as

  • 0

So I will try to discuss the specifics of my program as generally as possible while still getting the general point across. I have two objects of importance, the JobManager, and JobWorkers. A JobWorker has a task it is supposed to execute at fixed intervals until it is completed. I will ignore what happens when the job is completed, because they are never starting. I see the JobManager’s timer is being set off, but the JobWorker Timers are not being started. Below is some pseudocode to help you understand the situation.

public class JobWorker
{
    private String jobName;
    private Timer timer;
    private Calendar startTime;

    public JobWorker(String jobName, Calendar startTime, otherFields)
    {
        this.jobName = jobName;
        this.startTime = startTime;
        this.timer = new Timer("EmailJob" + jobName + "-timer");
        //set other fields
    }

    public void start()
    {
        timer.schedule(new TimerTask(){

            public void run()
            {
                //Do stuff - this is where nothing is happening
            }

        }, 0, 60000);
    }

    //Equals method and other stuff
}

public class JobManager
{
    private List<JobWorker> activeWorkers = new ArrayList<JobWorker>();
    private List<JobWorker> pausedWorkers = new ArrayList<JobWorker>();

    private Timer timer;

    public JobManager()
    {
        //loads workers from database

        timer = new Timer("JobManager-timer");

        loadJobs();

        timer.schedule(new TimerTask(){

            public void run()
            {
                //I see this statement every minute as expected
                logger.info("EmailJobManager timer run started.");

                for(JobWorker worker : pausedWorkers)
                {
                    Calendar c = new GregorianCalendar();

                    //I can see worker.getStartTime() in client gui so I know that they have already passed
                    if(c.compareTo(worker.getStartTime()) > 0)
                    {
                        //Never see these log statements
                        logger.info("Memory Address in manager timer loop 2 for " + worker.getEmailJobName() + " ({})", worker.toString());

                        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy - HH:mm");

                        logger.info("Comparing current time ({}) to JobWorker " + worker.getJobName() + " start time ({})", sdf.format(c.getTime()), sdf.format(worker.getStartDate()));

                        activeWorkers.add(worker);
                        pausedWorkers.remove(worker);
                        worker.start();
                    }
                }
            }

        }, 0, 60000);
    }

    public void addWorker(necessary fields)
    {
        //Create JobWorker newWorker = new JobWorker(jobName, blah blah)
        pausedWorkers.add(newWorker);
    }   

    /**
     * Checks to see if any jobs were not completed as expected due to hardware error. Recreates the EmailJob and EmailJobWorker responsible.
     */
    private void loadJobs()
    {
        String SQL = "SELECT * FROM email_jobs";

        List<Map<String, Object>> rows = jt.queryForList(SQL);

        for(Map<String, Object> row : rows)
        {
            JobWorker worker = new JobWorker(stuff it needs from SQL);

            //I see these debug statements
            logger.info("Worker " + worker.getJobName() + " has been added to pausedWorkers list with memory address ({})", worker.toString());
            pausedWorkers.add(worker);

            logger.info("Job " + jobName + " loaded sucessfully.");
        }
}

I am going to continue putting some more debug statements in, namely printing out JobWorker memory addresses (Object.toString essentially) to see if there is something weird with deep/shallow copies of them. Any ideas?

EDIT:
Okay, I am at a complete loss for what is happening. So here is the complete class.

http://ideone.com/hR7et

There is nothing sensitive in there so no worries.

Here is the log output I have:

2012-04-17 16:34:18,548 INFO [http-bio-8081-exec-97] c.c.e.EmailJobWorker [EmailJobWorker.java:98] EmailJobWorker test was created sucessfully. (batchSize, timeInterval, currentId, startTime) (1, 5, 1, 04/17/12 - 15:15)
2012-04-17 16:34:18,552 INFO [http-bio-8081-exec-97] c.c.e.EmailJobManager [EmailJobManager.java:297] Worker test has been added to pausedWorkers list with memory address (EmailJobWorker@7e7df7d)
2012-04-17 16:34:18,552 INFO [http-bio-8081-exec-97] c.c.e.EmailJobManager [EmailJobManager.java:301] EmailJob test loaded sucessfully.
2012-04-17 16:34:18,557 INFO [http-bio-8081-exec-97] c.c.e.EmailJobWorker [EmailJobWorker.java:98] EmailJobWorker test2 was created sucessfully. (batchSize, timeInterval, currentId, startTime) (1, 5, 1, 04/17/12 - 15:15)
2012-04-17 16:34:18,558 INFO [http-bio-8081-exec-97] c.c.e.EmailJobManager [EmailJobManager.java:297] Worker test2 has been added to pausedWorkers list with memory address (EmailJobWorker@349be26c)
2012-04-17 16:34:18,558 INFO [http-bio-8081-exec-97] c.c.e.EmailJobManager [EmailJobManager.java:301] EmailJob test2 loaded sucessfully.
2012-04-17 16:34:18,558 INFO [http-bio-8081-exec-97] c.c.e.EmailJobManager [EmailJobManager.java:117] EmailJobManager timer started sucesfully. (sleepTime) (1)
2012-04-17 16:34:18,559 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:74] EmailJobManager timer run started.
2012-04-17 16:34:18,561 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:85] Size of pausedWorkers: 2
2012-04-17 16:34:18,561 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:89] Memory Address in manager timer loop 2 for test (EmailJobWorker@7e7df7d)
2012-04-17 16:34:19,501 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:75] EmailJobManager timer run started.
2012-04-17 16:34:31,984 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:75] EmailJobManager timer run started.
2012-04-17 16:34:34,562 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:75] EmailJobManager timer run started.
2012-04-17 16:35:04,840 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:75] EmailJobManager timer run started.
2012-04-17 16:35:19,501 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:75] EmailJobManager timer run started.
2012-04-17 16:35:31,984 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:75] EmailJobManager timer run started.
2012-04-17 16:35:34,562 INFO [EmailJobManager] c.c.e.EmailJobManager [EmailJobManager.java:75] EmailJobManager timer run started.
2012-04-17 16:36:04,840 INFO [EmailJobManager] c.c.e.EmailJobManager 

As you can see the timer is not even going off every minute, even though EmailJobManager is only created once, and the timers for JobWorkers are never set off.

  • 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-06-02T10:13:11+00:00Added an answer on June 2, 2026 at 10:13 am

    I see the JobManager’s timer is being set off, but the JobWorker
    Timers are not being started.

    Are you calling JobWorker.start? You need to include more code so we can see what’s happening. There’s no reason those run methods shouldn’t execute: http://ideone.com/uEer3

    Transience is only relevant in serialization.

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

Sidebar

Related Questions

I will try to keep this as simple as possible. I have a rather
I will try to explain my problem clearly: I have two tables: document and
Ok I will try to explain this as much as possible. I have a
I will try and explain this as concise as possible. I have 2 objects,
I will try to describe it as simple as possible. We have SqlConnection and
I will try to be as brief as possible... I have published a very
I will try to be as clear as possible because I can't get anybody
I have a problem and I will try to explain the issue: I have
I will try my best to explain this. I have an application that show
I will try and ask my question clearly... I have three tables that each

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.