Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
Vineeth Arvind
Greenhorn
+ Follow
news
1
Posts
0
Threads
since Jun 07, 2011
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads
Recent posts by Vineeth Arvind
Scheduling task execution in defined intervalls
Try if This might help. This is using Timer and TimerTask. Currently i'm using threads for tasks.
You can change accordingly.
[color=brown]import java.util.Date; import java.util.Timer; import java.util.TimerTask; class MyTimerTask extends TimerTask { public void run() { System.out.println("Timer task with Date."); } } public class time1{ public static void main(String[] args){ MyTimerTask myTask = new MyTimerTask(); Timer myTimer = new Timer(); Date date = new Date(); /* * Set as today's Date, then repeat every 10 seconds(present in milliseconds, to be converted accordingly). */ myTimer.schedule(myTask, date, 10000); try { Thread.sleep(50000);//Sleep after 50 seconds } catch (InterruptedException exc) { } myTimer.cancel(); } }[/color]
show more
13 years ago
Threads and Synchronization