Back | Reverse | Quick Reply | Post Reply |

Constantly running background class?
Link | by hello on 2010-05-25 14:18:45 (edited 2010-05-25 14:24:25)
I meant to say operation.

I'm trying to make a program that does 2 things at once. More specifically, a bank account. On top of its regular classes to modify variables, it also has a hidden timer to calculate interest rates. Right now, the regular classes are built in gui mode, but I don't know how to constantly get the timer running.

Currently, it checks the time after every action done in the gui if its time to add interest, but its very irregular, such as 4:12:26, 4:14:35, 4:15:06. If they freeze on a screen for like 6 minutes then do an action, it will look something like 4:35:22, 4:35:22, 4:35:22, 4:35:22, 4:35:22, 4:35:22, which isn't right.
What I need it to do is something like 4:12:26, 4:13:26, 4:14:26, etc.

Any help is appreciated.

No.

Re: Constantly running background class?
Link | by gendou on 2010-05-25 14:58:58
This can be accomplished using Threads.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html

For the bank account project, use of Timers may be helpful.

When using multiple threads, be sure to avoid unwanted Race Conditions!


Back | Reverse | Quick Reply | Post Reply |

Copyright 2000-2024 Gendou | Terms of Use | Page loaded in 0.0022 seconds at 2024-05-16 20:25:23