Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

Need Help with Timer Class

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

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?

Forget Steve. Look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!