Using TimerTask to Do Stuff at Intervals
If you've ever used a UNIX cron job, you're used to needing to do stuff at timed intervals. Say you want to gzip the log files and move them in an archive every night at 3 a.m. Or maybe you need to start a process that will go out and check a server for some kind of update, and you want to check it every hour.
I once wrote an application that received user signups, and wrote them to a file. There were a lot of signups every day, but there wasn't a need to act upon them immediately. So the client asked that every hour we would do some junk to the data and then transfer it over to their AS/400 via FTP. Then they would do some junk to the data over there, and my app would check every couple of hours to see ...
Get Java Garage now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.