Groups | Search | Server Info | Login | Register
| Newsgroups | comp.sources.d |
|---|---|
| Date | 2017-01-04 13:22 -0800 |
| Message-ID | <8a411398-f9b8-4272-bb26-3007ec8587de@googlegroups.com> (permalink) |
| Subject | Realizing periodic interruptions in code execution |
| From | sandeep6699@yahoo.com |
Hi netizens, I had posted a query on stackover regarding periodic interruptions in code execution (http://stackoverflow.com/questions/41459456/java-realizing-periodic-interruptions-in-code-execution/41460518). My query was as follows: "How to realize the following: After every 10 minutes interrupt your business logic and go to sleep for 5 minutes" My original query was Java specific and I got a great response for my query. Actually the response is language neutral, hence the posting to this newsgroup. Refactor the code so that it looks like this: Business-logic LOOP BEGIN Execute business logic Business-logic LOOP END Now to this, make the following changes: DEF WorkingInterval, SleepInterval, startTime startTime = currentTime() Business-logic LOOP BEGIN IF(currentTime() < startTime + WorkingInterval) Execute business logic ELSE BEGIN sleep(SleepInterval) startTime = currentTime() ELSE END Business-logic LOOP END I think the proposed solution is pretty elegant. Any other simple alternatives come to mind? Regards, SS
Back to comp.sources.d | Previous | Next | Find similar
Realizing periodic interruptions in code execution sandeep6699@yahoo.com - 2017-01-04 13:22 -0800
csiph-web