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
0
votes
1 answer

Java TimerTask expected

Why does java keep giving me this error? I have read multiple ways to use timer and all have given me expected error I have been trying to get this for a while now. private class buttonRowColumn implements ActionListener { …
jturk98
  • 5
  • 3
0
votes
1 answer

Android TimerTask big imprecision

i have a problem using TimerTask in android. The situation is this one: I have a class extending AsyncTask, cal it MyAsyncTask, and i have a static method in another class, call it SchedulerClass. SchedulerClass has this method TimerTask…
Apperside
  • 3,542
  • 2
  • 38
  • 65
0
votes
1 answer

Timer util wont add a new line for JLabel

Why is that When I user the Timer.util the JLabel wont allign with my String that I inserted in my JTextPane? But when I use the Timer it Allign. I need the Timer.util for my database so it wont lag. Here is the image when I use the Timer…
0
votes
1 answer

android popup window of image when screen interaction idle for a 10 seconds

I have a problem trying to implement a popup image when screen of android phone is left idle or unused for 10 seconds. Currently I am using a timer but need to implement an on-idle listener instead but I have no idea how this can be done. Can…
PhillyT
  • 15
  • 6
0
votes
2 answers

Android Java Timer()

I'm using Timer() due to its accuracy but works in the same was as PostDelayed Handler. It's called only once. Here is the Timer code: public void setWFT() { WFT = new Timer(); WFT.schedule(new TimerTask() { …
KickAss
  • 4,210
  • 8
  • 33
  • 41
0
votes
1 answer

android , can't alter text views and set button visible in Timer Task

I'm having a problem and i Can't solve it. In my activity, I got a function that returns if the phone is connected to Wifi or 3g . When I open onCreate() I make the initialization of variables and I run a TimerTask for 5 in 5 seconds, to test if the…
cpfp
  • 377
  • 1
  • 4
  • 15
0
votes
1 answer

Singlethreaded ScheduledThreadPoolExecutor with calls limit

I would like to utilize the java.util.concurrent.Executors to fire some runner. The problem is that i wanted to fire it fixed amount of times. It is important to call those runners a fixed rate. For me it is perfectly sufficient use a…
maryoush
  • 173
  • 1
  • 12
0
votes
2 answers

TimerTask and AsyncTask implementation across APIs

I found that AsyncTask and TimerTask do not behave the same across different API versions. Here's my setup: A TimerTask is set to fire every once a while. There is a service whose method is called when the TimerTask fires. That method instantiates…
0
votes
2 answers

check if the timer has any pending tasks?

I use the Java's Timer to schedule a task to run after some interval of time. myTimer.schedule(myTask, delayTime); At any point in time, is it possible to check if there is any task scheduled to be run (but has not run yet)? If so, how would I do…
One Two Three
  • 22,327
  • 24
  • 73
  • 114
0
votes
2 answers

how set TimerTask for PrintWriter?

I am using TimerTask to send messages every 3 seconds, but its sending only one time. public static void main(String[] args) throws IOException { soc = new Socket("localhost", 12345); out = new…
Max Usanin
  • 2,479
  • 6
  • 40
  • 70
0
votes
2 answers

Checking Whether a Task Has Succeeded Before Timer Expires C# (Multi-thread)

I have a scenario in which a parent thread spawns multiple task/job threads (done by someone else). At the end, I need to perform one additional task which is unrelated to the job threads. What I need is to execute this new task (checking for…
Malvon
  • 1,591
  • 3
  • 19
  • 42
0
votes
1 answer

Thread and mediaplayer problems, Timer with sound

I'm developing an Android application that is based on a timer that every second must play a sound that you selected before. Here is the problem: No objects can run Media Player in a Thread or a Runnable I can not call methods that reproduce the…
CristianCV
  • 342
  • 1
  • 5
  • 17
0
votes
1 answer

Android: how to switch with timer?

I am trying to activate a sound with an switch widget, so I can turn it off as well. Though I also want it to shut down automatically of after a few seconds. everything works though the app crashes on s.performClick(); anyone know how to fix the…
0
votes
4 answers

Updating UI on button click after a certain time

I have a TextView. I want to update its text (append a "1") after 1 second of a button click. public class HaikuDisplay extends Activity { Method m; Timer t; /** Called when the activity is first created. */ @Override public void…
Shashwat
  • 2,538
  • 7
  • 37
  • 56
0
votes
2 answers

TImerTask on paintComponent

I have used a TimerTask to add a timer on a loop on one of my classes which is called by the paint component class. Basically there are white circles on the page already painted, there is then a for loop which reads a value from an array and…