Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Realizing periodic interruptions in code execution

14 views
Skip to first unread message

sande...@yahoo.com

unread,
Jan 4, 2017, 4:22:36 PM1/4/17
to
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





0 new messages