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
3
votes
5 answers

Scheduling a task in java

In my java web application, I want to schedule a task. I have searched the web alot and couldn't find a suitable scheduler for my case. In the application I have different types of users. For a specific user type, I want to schedule a task. By the…
nudaStck
  • 311
  • 2
  • 6
  • 18
3
votes
2 answers

Android: Restart Timer

I created a TimerTask with the following code: Screen_Timer_Task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { …
Jan Knoblauch
  • 219
  • 1
  • 3
  • 20
3
votes
1 answer

Timer task and Thread and inner Class

Hi everybody . I developed following code. The purpose is : Printing the current time every 500 ms on the screen . This should take place inside a thread . my code doesn't work and I don't know…
Danial
  • 703
  • 1
  • 11
  • 26
3
votes
1 answer

ConcurrentModificationException TimerTask

I get ConcurrentModificationException when I start a second timer after canceling the first one. Both timers uses a separate ArrayList and iterates through it. No removal/modification is performed on the list, still there is thrown…
yonikawa
  • 581
  • 1
  • 9
  • 32
3
votes
2 answers

Specific TextView in GridView not updating on app init

I have 4 TextViews in a GridView with a custom adapter in a given Fragment. My main Activity gets notified via a TimerTask to update the text color for the correct TextView. This works fine for all the TextViews except the first one when the app…
Itamar Bitton
  • 777
  • 2
  • 7
  • 25
3
votes
1 answer

How to cancel timerTask for AsyncTask in android

Hi I am working on TCP socket. I can read data for every 1 sec. to achieve it I used TimerTask as shown in below code. Handler handler = new Handler(); Timer timer = new Timer(); TimerTask doAsynchronousTask = new TimerTask() { @Override …
user2085965
  • 393
  • 2
  • 13
  • 33
3
votes
2 answers

Timer for an editText Box : Only the original thread that created a view hierarchy can touch its views

I am trying to make the edittext boxvibrate and change color momentarily if a wrong password is entered final Drawable oldBackground = findViewById(R.id.email).getBackground(); TimerTask timerTask = new TimerTask() { @Override public void…
cxzp
  • 652
  • 2
  • 14
  • 28
3
votes
1 answer

TimerTask is already scheduled

I have a MediaPlayer object which plays a local audio file. I am using a TimerTask to update the position of a SeekBar and text on a TextView while the audio plays. There is one button. When the user presses the button audio starts. When they press…
user470763
3
votes
0 answers

Spring - TimerTask implementation running twice

I have a simple TimerTask implementation that just prints to the System.out public class RefreshUserAndOLStatsJob extends TimerTask { public void run() { System.out.println("RefreshUserAndOLStatsJob running at: " + new…
arahant
  • 2,203
  • 7
  • 38
  • 62
3
votes
3 answers

How to implement a efficient timeout in java

There are n object which perform some actions. After performing an action a timestamp will be updated. Now I want to implement a timeout-thread which verifies if a timestamp is older than for example 60 seconds. My first solution was to do that…
stormsam
  • 179
  • 1
  • 2
  • 10
2
votes
2 answers

How to make timer task to wait till runOnUiThread completed

I need to update UI after certain time period, for which I have create a timer schedule and inside it I am calling the runOnUiThread. timer.scheduleAtFixedRate(new TimerTask() { public void run() { …
Adil Bhatty
  • 17,190
  • 34
  • 81
  • 118
2
votes
5 answers

Pausing a timerTask

I have hit another wall. After getting my key input working, I have been racking my brains for hours, i want to create a pause function, so that if the same key is pressed again the timertask stops running (i.e the game is paused) JPanel component =…
Sam Palmer
  • 1,675
  • 1
  • 25
  • 45
2
votes
5 answers

Can run() return objects?

Assuming that this is the scenario: class A extends TimerTask{ int a; public void run(){ //operation to be performed periodically } } and class B{ int delay=2000,interval=3000; A objectA; public static void main(String[] args){ …
P R
  • 1,293
  • 7
  • 28
  • 58
2
votes
1 answer

Showing Timer in android

My objective is to display a simple timer clock on my screen where it starts from 20 and goes on decreasing and when it becomes 0 I want to start an action. How to achieve this ? Thanks in advance
Ankit
  • 4,426
  • 7
  • 45
  • 62
2
votes
1 answer

Why do some of my timers not execute their tasks at all?

I'm developing a multi-timertask project. First of all, I design some classes extended TimerTask and override the run() method. In the run() method, a line will be printed with current time. Secondly, a Timer is initialized like…
edward
  • 25
  • 1
  • 6