Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Brian, I figured out a solution a bit after posting my question. What I did was to use an int variable that keeps track of how many tasks are actually run at that precise moment. Then, if the variable is greater than 0, I cause the thread to sleep for 60 seconds. The reason for this is that if you look at the code I provided, I was using an endless while loop (which ran as a seperate thread) to continually check if a scheduled task was supposed to run. The problem was that the time specified in the file was the hour and minute, which meant that the while loop would iterate quite a lot of times during the span of that minute. That is why the minute (no pun intended) the current time hits the time of the scheduled task, and the task runs, I pause the thread for 60 seconds, thereby eliminating the task being run multiple times for each iteration within a minute. Also, I do this after the if statement, so that all tasks are run (at least, I think so...haven't tried w/ multiple tasks at the same time yet...should do so now i guess). Anyway, thnx for the suggestion of having a bit that specifies when to do the task next and updating that. Essentially what I'm trying to do is create an application that simplifies scheduling tasks and setting programs to start when the computer starts up. By the way, do you know how to either create an exe file out of a java project, or run the java project automatically (ie, without the project file being double clicked on). The reason I'm asking is because I need to have the install program place my application in the startup folder to run whenever windows starts (I'm gearing this for windows right now). Except that my application will be in byte code (and possibly in a JAR file). So, how do I execute that w/o having the user manually run it using the java.exe program?
Replies:
|
Sponsored Links
|