Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Timers Question

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Suppose I have two timers in a game running at the same time. The first is set for updates every 1 sec, and the second every 10 secs. What happens when the two timers coincide? Suppose both timers update the same database.

best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alexis,

this very much depends on what the timed tasks should do. Is it (at least in theory) possible for the two tasks to run in parallel? For your example with databases there are a lot of things which could make a difference. Is it read or write access? The same data? Same database? Are you using transactions? And so on...

Moreover it may also depend on your hardware. Even if it is possible to run two tasks in parallel in theory and your application is programmed with multithreading it's not possible to execute two threads at the same time on a single processor/core machine. They may appear to a human as if they would run in at the same time, but they don't. Even with multicore processors it may depend on lots of other things if the tasks can really run in parallel.

Another important point that comes to mind is the required accuracy. Is it enough if the said tasks execute within the same minute? Second? Millisecond?

As you see it's almost impossible to give a general answer to your questions which would be valid for all usage scenarios. You have to know some more specific requirements...

Are you here to take over the surface world? Because this tiny ad will stop you!
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic