• Post Reply Bookmark Topic Watch Topic
  • New Topic

CountDown Timer  RSS feed

 
Marcus Senna
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to implement a countdown timer. Can anyone give me some assistance. Thanks!!
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following link may help

SourceForge Countdown Timers
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
depends on what you want...

umm...

you can use java.util.Timer

or you can just create a thread




Justin
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Justin Fox:
...or you can just create a thread...

If you're just calling sleep, there's no need to create a new thread object, because the sleep method is static.

Marcus: This sounds like a homework assignment. Can you tell us more about what the requirements are, what you've tried, and where exactly you're stuck? I'm sure we can help you, but we need more information.
 
Marcus Senna
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, actually it is part of my final year university project.
I am creating an application which allows users to simulate certain communications protocols. This application would allow users to configure networks using network components such as routers and hosts by dragging and dropping images of them onto a configuration area and setting up links between them. I would like to achieve the effect of a propagation delay when data is sent along links between the nodes. I tried using the java.util.Timer class along with the java.util.TimerTask class, but I am getting problems because of thread synchronization issues(i concluded this, I could be wrong).
I found a class online, timer_engine, which is a virtual timer and right now i am trying to incorporate it into my system. Below is a thread I was trying to write to do the propagation delay.

Bascially, i have a class called Link, which has a vector called Data which stores the DataUnit objects being sent and routed by Host and Routerobjects. The above thread is first checking to see whether the vector is empty. That is the problem i am having; although i am doing this check before I do anything to the vector, i am still getting this exception: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
I don't know if i have explained myself well enough, so i will stop here and wait for your feedback. Thanks!!!
 
Marcus Senna
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
timer_engine class I found online:
 
Marcus Senna
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I modified the timer_engine class a bit, to suit my application
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!