Questions tagged [timertask]

Timertask is a Java API class. Logically it represents a task that can be scheduled for one-time or repeated execution by a Timer

A TimerTask implements Runnable, also has a method to cancel the scheduled task, if required. It is used with java.util.Timer (Swing timer fires action events).

A concurrent package contains several classes that are similar to TimerTask by concept but provide additional funcitonality.

917 questions
-1
votes
1 answer

Different handlers for ejb Timer

I'm trying to set different handlers for different types of tasks created via TimerService , ejb. I need to figure out a way where I can create a schedule tasks with extra information including the handler type so when a timeout occurs different…
Mickey Hovel
  • 982
  • 1
  • 15
  • 31
-1
votes
2 answers

Timer not able to execute task

I am trying to execute a task periodically. For example: class MyTimerTask implements TimerTask { public void run() { // Some actions to perform } Timer cleaner = new Timer(true); cleaner.scheduleAtFixedRate(new MyTimerTask(), 0,…
-1
votes
3 answers

android how to increment seconds in date time text view

i have a textview having a specific date time string as this format dd/MM/yyyy HH:mm:ss. I need to create a thread that increment number of second in the textview every one second so its update : minutes, day, month year.... how to create this…
Amalo
  • 772
  • 3
  • 13
  • 32
-1
votes
1 answer

Timer task implementing handler

UPDATE : The code is working only that I dint init the textview, but this question is answered so I cant remove it either. So I will leave this question as it is for anyone trying to implement a Timertask with handler that makes use of…
user3599100
-1
votes
2 answers

Java - Printing message as long as TimerTask is running

Below is a test Timertask class that i have been experimenting with. Basically the timertask watches when a file changes and then executes some methods. I want a message printed to the user, eg."Waiting for file change to occur" as long as the…
spry
  • 3
  • 2
-1
votes
2 answers

"Only the original thread that created a view hierarchy can touch its views." error when using TimerTask

I have created an app composed of one single activity which include a single TextView. Here is the XML of my activity : activity_main.xml
Anwar
  • 4,162
  • 4
  • 41
  • 62
-1
votes
2 answers

Why Timer commands work at the same time in java

I have a problem about Timer in java. When I run the code below, a.start(0), a.start(1) and a.start(2) are being printed at the same time and the output is like 02121010120010122012102 but I want to be printed in order like…
tntnt44
  • 9
  • 2
-1
votes
2 answers

I'm trying to use java.util.timer to schedule a task periodically; i'm not sure how

I have researched for some time different methods to schedule a task after a certain amount of time (ie. Quartz, ScheduledThreadPool, java.util.timer) and I'm having problems understanding how to use it. Here is just an example I found from my…
Toni
  • 5
  • 5
-1
votes
1 answer

Increasing counter in TimerTask

How can I increase my counter i here: private void startTimer() { int i = 0; final Timer timer = new Timer(); final TimerTask task = new TimerTask() { @Override public void run() { …
Dim
  • 4,527
  • 15
  • 80
  • 139
-1
votes
1 answer

I want to do animation in android with alternate time period.

For example: The view will animate, it will wait for 4 seconds as it is, again it will animate and it will wait for 2 seconds and then again 4 and 2 secs continously. I tried using scheduleAtFixedRate method from Timer class. Its working for any one…
Javed Khatri
  • 719
  • 2
  • 7
  • 9
-1
votes
1 answer

Interface extending TimerTask

I'm working on getting my interface to extend TimerTask in Java. But my code will give the next error: "Interface expected here" at the declaration of the interface. import java.util.List; import java.util.TimerTask; public interface…
Guido
  • 1,161
  • 3
  • 12
  • 33
-1
votes
1 answer

ERROR: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views

I'm getting results from the server as the user types in his request. Initially I was firing a request on each character entered. Now, I've put a delay of 500 ms after user types in his last character & then I fire the request to fetch results from…
Aishwarya Tiwari
  • 625
  • 4
  • 19
-1
votes
1 answer

How to force a timer to start immediately

I am using a timer that should every 12 seconds issues a warning. as shown in the code below i set the delay to 0 so that the timer starts immediately, but at run time, the below posted timer does not starts immediately it waits for the period set…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
-1
votes
1 answer

How to reschedule/remake a timer?

I've tried Timer and TimerTask and they don't seem to support rescheduling Here's the code that runs the timer, the start method is called and throws a non-descriptive exception import java.util.Date; import java.util.Timer; public class…
Butterscotch
  • 100
  • 11
-1
votes
1 answer

Timer switch android TimerTask

b= new TimerTask() { @Override public void run() { out_string = hi.getWebPage("http://daniandroid.honor.es/getAllCustomers.php"); frum_timer = Integer.parseInt(out_string.replaceAll("[\\D]","")); }; };…
Xan
  • 45
  • 8