Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Help with Timer Class

 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a assignment where I have to make a scheduler that when you add a task and a time when the time runs out it should show that scheduled task no matter what your doing.

So I figured out how to do most of it expect one thing.

Say if you add these tasks:

Task: my first task
Time(in seconds): 10

Task: my second task
Time(in seconds): 2

now Task2 will go before Task1(unless your really slow and took 10 seconds to add task2).

Now how I have it right now when the TimerTask happens it takes whatever is in the Task field and displays it.

This of course is not what should be happening since what will happen is when I write "my second task" and add that to the schedule and the 2 seconds go by it will display "my second task" but when "my first task" comes along it won't display "my first task" instead it will display "my second task" or any thing what is written in the Task textbox at that given time.

I have no way of actually storing the tasks. The problem is I don't know how to store the tasks so they go in order.

How would I store them and then make sure the right task gets called up at the right time?

Thanks
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!