0

i have a GUI with play and pause buttons. play button when pressed, schedules a timer according to a time stamp read from a file and publish some data t the network according to the time stamp. For an example, if the fie i am processing has the following timestamp:

.00111 .0222 .025585

after first time stamp data will be publishe dto the network and so for the rest of the entire time stamps.

despite when pause button is clicked, i cancel and purge the timer, i receive the below errors from the console.

why i receive such errors as long as i cancel and purge the timer.

Update_1

is the console o/p could be just because of too many qeued timers were scheduled and after pressing pause "timer.cancel and timer.purge) theycan not be run/scheduled" anymore?

console o/p after pause buton is pressed:

Exception in thread "TimeStampThread_1_29.372000000003" java.lang.IllegalStateException: 
Timer already cancelled.
at java.util.Timer.sched(Unknown Source)
at java.util.Timer.schedule(Unknown Source)
at org.eclipse.paho.sample.GuiMenuBar$TimeStampTimerThread.run(GuiMenuBar.java:966)
at java.lang.Thread.run(Unknown Source)
Exception in thread "TimeStampThread_1_29.252000000000" java.lang.IllegalStateException: Timer    
already cancelled.
at java.util.Timer.sched(Unknown Source)
at java.util.Timer.schedule(Unknown Source)
at org.eclipse.paho.sample.GuiMenuBar$TimeStampTimerThread.run(GuiMenuBar.java:966)
at java.lang.Thread.run(Unknown Source)
Exception in thread "TimeStampThread_1_29.302000000003" java.lang.IllegalStateException: Timer 
already cancelled.
at java.util.Timer.sched(Unknown Source)
at java.util.Timer.schedule(Unknown Source)
rmaik
  • 1,076
  • 3
  • 15
  • 48
  • You may want to include some code. BTW the error looks like something you would get if you wanted to restart a cancelled timer (something you cannot do with java timers) – Ordous Jan 07 '15 at 14:35
  • @Ordous thanks for the comment. is this could be because what i mentioned in updat_1 section above in the question? is it errors or just something like warnings – rmaik Jan 07 '15 at 14:37
  • Quoting the Javadoc on `Timer.schedule()`: "`IllegalStateException` - if task was already scheduled or cancelled, **timer was cancelled**, or timer thread terminated.". I have a very strong feeling that this is exactly what you are trying to do and you need to create a new timer instead of reusing the old one, but I can't be sure until I see your code :) – Ordous Jan 07 '15 at 14:57
  • yes i ahve only one timer, because i need only one timer to start from zero to fire action according to the timestamps, for an example, timestampe 2s, 3s,4s,5s...10s. i want my timer to start only once from zero, and when 1s is reached an action should be done, the when 2s is reached the same thing again up to 10s. if i used new timer every time, first timer will wait 1s and the seconds timer will wait 1s+1s, and the third will wait 1s+2s and the tenth wil wait from 0s->10s, and such way is not suitable in the application i am developing – rmaik Jan 07 '15 at 15:26
  • Why can't you have a single timer, and create a new one *only after a pause was lifted*? (Like in this [answer](http://stackoverflow.com/questions/11550561/pause-the-timer-and-then-continue-it)) – Ordous Jan 07 '15 at 15:55
  • @Ordous i do have a newly timer created every time pause is lifted – rmaik Jan 08 '15 at 08:04
  • Well then can you post some code please? I can't read your mind and tell you what's wrong without seeing it. – Ordous Jan 08 '15 at 13:27

0 Answers0