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

is it possible to create Singleton non-persistent ejb timer?

I am using an EJB automatic timer service with @schedule annotation. However I need help with the following. I need a singleton time service (execution on only one node in a cluster) but don't want to execute missed timers during server restart or…
Sumanth
  • 595
  • 3
  • 14
  • 39
2
votes
5 answers

Android: Implication of using AsyncTask to make repeated Ajax Calls

I need my Android app to periodically fetch data from a server using AJAX calls, and update the UI accordingly (just a bunch of TextViews that need to be updated with setText()). Note that this involves 2 tasks: Making an AJAX call, and updating…
curioustechizen
  • 10,572
  • 10
  • 61
  • 110
2
votes
1 answer

Android Studio changing TimerTask() period while executing possible?

I have a small game that spawns an enemy at a random position and keeps teleporting to another random position every second. My problem is that I dont know how to make the teleportation faster as the timer keeps decreasing. My timer starts at 60…
Hasbulla
  • 85
  • 1
  • 7
2
votes
1 answer

How to use TimerTask on flutter?

I want to create a function that runs every x seconds .. in java there is the TimerTask but in flutter what is it?
Gerard_jcr
  • 289
  • 2
  • 13
2
votes
2 answers

Writing JSON using Jackson blocks my TimerTask

I would like to write some JSON every 5th second. I'm using Jackson to write the JSON, but it seem to block my TimerTask. If I don't write JSON, the TimerTask is run every 5th second, but when I try to write JSON it's blocked and only run once. How…
Jonas
  • 121,568
  • 97
  • 310
  • 388
2
votes
2 answers

NULL Autowired object in Main method while using it in Timer class object

I am running springboot application with TimerTask my object of service is showing null. I have tried various methods but unable to get rid of the Null pointer exception. main class . @SpringBootApplication @ComponentScan(basePackages =…
Akshay Busa
  • 125
  • 7
2
votes
0 answers

User editable countdown timer

Let me start by I do not know javascript( I am watching videos online, reading books, udemy workshop) but building my first website. I want to be able to have an countdown timer that any user can edit but I only need minutes and seconds. I have a…
Grant
  • 31
  • 1
2
votes
1 answer

Running a method every day at a specific time with Timer()

Using Kotlin, Bukkit (Spigot), and Timer() (Or anything that also helps), I'm trying to create a way that I can run another method, every day at a specific time. Here's what I have so far, which doesn't work. fun schedule() { val timer =…
kinx
  • 463
  • 5
  • 12
  • 31
2
votes
2 answers

Use ScheduledExecutorService to run code at specific Date time only once

I have a code that has to be executed at a certain date time in the future, let's say that I have a future date and I want to execute a peace of code in that date +1 minute in the future, but only once. I know I to do this with a java Timer and…
navy1978
  • 1,411
  • 1
  • 15
  • 35
2
votes
2 answers

Argument mismatch; method cannot be converted to TimerTask

I keep getting this kind of error: error: no suitable method found for schedule(soccer,int) method Timer.schedule(TimerTask,long) is not applicable (argument mismatch; soccer cannot be converted to TimerTask) method Timer.schedule(TimerTask,Date)…
2
votes
1 answer

Redraw Drawable by timer using invalidateSelf() not working

I have my class implements Drawable. I need to redraw it periodicaly to get some "blink" effect. I am using timer.schedule to schedule invalidateSelf() but nothing happend. private class DrawableImpl extends Drawable { private boolean blinkFlag…
hatesms
  • 750
  • 1
  • 9
  • 27
2
votes
1 answer

How to cancel a timer from another scene JAVA

I have tried reading the java docs and have done quite some research but none works. Basically, when I change a scene, I want the timer to cancel. Code for timer.Omitted the part where I created the timer. When I initialize, I will call the timer…
zzdhxu
  • 379
  • 6
  • 22
2
votes
1 answer

How to open an activity at a pre-determined time from boot up

I need my app to open at a scheduled time. I've searched for the best way of doing this and have got quite confused. I'm currently using BroadcastReceiver to respond to onBoot. That works fine but which way is best to go next? Should I set up an…
2
votes
1 answer

How to submit a TimerTask to another Timer when it 's running

In a run method of a TimerTask object, How can I submit the timerTask itself to another Timer. When the timerTask is running, I should do a judge and decide whether it can do some work. If it not meet the condition, I should cancel it and put it to…
zaihui
  • 53
  • 1
  • 9
2
votes
1 answer

How to Implement Scheduled Task in Spring Web Service?

I am developing Java REST Web Service using Spring and Hibernate. I need to implement a feature to schedule a future task. For example, When User Sign Up in my application I have to credit him 100 virtual credits to his account for first six months.…
Mdumanoj
  • 517
  • 3
  • 9
  • 27