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

finally{timer.cancel();} not being reached in a transaction

We have the following transaction that sends a heartbeat while it is a running. However in certain situations the heartbeat timer never stops, and the system keeps sending heartbeats even if the transaction is not running. Are we doing something…
Saqib Ali
  • 3,953
  • 10
  • 55
  • 100
0
votes
2 answers

how to return specific response in jersey service

i have a jersey service which contains a timer task, which polls for a particular value. i want to return a response only when i get a particular value from the polling. is there any way i can accomplish that? My code is: @Path("/poll") public class…
Gaurav Sood
  • 680
  • 4
  • 17
  • 38
0
votes
2 answers

how to execute the code in the specific time using timertask

Hi this is my listener class public void contextInitialized(ServletContextEvent arg0) { // TODO Auto-generated method stub System.out.println("inside listener context"); Timer timer = new Timer(); Calendar cal = Calendar.getInstance(); …
user2838630
  • 91
  • 1
  • 5
  • 15
0
votes
0 answers

android timer: how to do right thing

I want to log when something happened and delay 1 minitues. so I use a timer and timertask live this: private Timer _checkTimer; private boolean _timerStart = false; private void requestPlayPosterItem(long id) { // if(_timerStart…
BollMose
  • 3,002
  • 4
  • 32
  • 41
0
votes
1 answer

Execute JSON reading in services via TimerTask

So what I want to do, is execute JSON reading in a service every X seconds/minutes/hours/whatever. When I try this code, it does not work, giving me an error like this: https://i.stack.imgur.com/nGkZR.png I am quite new to Android…
0
votes
2 answers

Spring Implementation - Recurring Timer

I have seen various thread on timertask issues. However I would like some clarification on the inner working on spring Scheduler APIs (3.1). I have a requirement to kick off a timer every 10 secs. The application runs in clustered websphere zos.…
0
votes
1 answer

What can be the reasons for a TimerTask to stop running in a Tomcat Servlet

I suspect an exception could make the TimerTask stop running in which case I most likely need a second timetask to monitor that the first is still running? Update Thanks for the answers. I had inherited this code so a bit ignorant... I just saw that…
Menelaos
  • 23,508
  • 18
  • 90
  • 155
0
votes
1 answer

Scheduling a Class or Writing a queue

My Requirement is to deal with the long running method in a java class , which is called when the user submits a button. I need to do some comparing logic which would take long time to process and i need a suggestion whether i should go with message…
Manish Sahni
  • 488
  • 2
  • 7
  • 21
0
votes
1 answer

Can not stop TimerTask

I have a problem with my Java code when doing with Wii Remote. My situation is "When button A presses, print something to the screen (the raw acceleration in my case) until releasing button A", so, after few days of searching, i use TimerTask and…
Lup
  • 197
  • 1
  • 1
  • 7
0
votes
0 answers

How to create a stopwatch timer without using "chronometer" class and just by using"SystemClock"--Android Phone App Developement

How can we write a stopwatch timer similar to the following (with the same functionality) without using chronometer class and solely by using "SystemClock" class? Most of the examples I have seen so far are either just using chronometer class or a…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
0
votes
1 answer

Start Multiple java TimerTasks at the same time

Is it possible to schedule multiple TimerTasks such that they all begin at the same time and if so how would I do it? In particular I would like to initiate these tasks at the same exact time so that the relative time difference between each task…
HXSP1947
  • 1,311
  • 1
  • 16
  • 39
0
votes
1 answer

Timertask stopping when screen locks

I'm using timer task to send updates on my API. The problem is, when the device is inactive, I don't really know the exact state. The timertask stops. Then when I unlock the screen and navigate again, the task started again. Here's how I do…
Luke Villanueva
  • 2,030
  • 8
  • 44
  • 94
0
votes
2 answers

Service crashes with nullpointerexception at onCreate

i wanted to check the actual time every 5 mins in a service and mute or unmute the phone depending on the time. earlier i tried to use a while(true) with thread.sleep(300000) at the end, but it crashed always with a ANR, so i tried to use a timer…
ntm
  • 731
  • 2
  • 13
  • 37
0
votes
1 answer

HTTP Connection thread doesn't update result inside TimerTask - BlackBerry Java

I'm doing a http call with kSoap within a TimerTask so I can update the data something like every five minutes. After getting the data from a web service I provide them to an interface via the function procecssData(). This works out perfectly for…
Musipoo
  • 11
  • 2
0
votes
4 answers

A contradictory in Thread's work in android

I tried to change my UI from my TimerTask and I recognized that it is impossible, because the TimerTask runs in a background thread and background threads are not allowed to change the UI. Now my question is: I was changing a ProgressBar and a…