I am a .NET programmer, founded in math. I am having an argument with a fellow programmer. When I add a Threaded Timer to the program, the interval in milliseconds I use is always a prime number.
My coworker (and seemingly the vast majority of programmers everywhere), insists that even, round numbers are sufficient. As an example, he will use 200 ms, 900 ms, 400 ms. I tend to use numbers which are either prime, or at the very least, meaningful to me (a former address, phone number, etc.)
I haven't been able to find much in the way of support on the internet. I read one entry in this forum which alluded to the harmonics of machinery. Wouldn't, then, a computer program be analagous to machinery? A computer program is a virtual machine, and any machine runs only as well as it was put together. It would seem that if too many "round" numbers were used (the multitude of milliseconds that are multiples of 100), then eventually some harmonics would emerge.
Harmonics in computer software manifest themselves in ugly ways, like glitches, skipping, and abrupt visual sequences.
Can anyone verify this assertion? I will place this in both Mathematics and Stack Overflow since there is a strong overlap.
We share profession (and indeed right know I am programming using .NET as well) and in my case is the first time I hear about the possible problems of harmonics in computer programming. I think the harmonics would not be a problem at all as the rest of people said in the comments.
But in other hand, you could have a point if the reason of using prime numbers in the threads is avoiding to compete with other processes massively for very few system resources. For instance, there is a very well known history about prime numbers and cicadas the insect that after 13 or 17 years, emerges from earth synchronously with the rest of cicadas. As Wikipedia says, it is hypothesized that the emergence period of large prime numbers (13 and 17 years) was a predator avoidance strategy adopted to eliminate the possibility of potential predators receiving periodic population boosts by synchronizing their own generations to divisors of the cicada emergence period.
In the case of the threads (the cicadas) of your program, if each thread competes with other threads (the predators) massively to obtain system resources it might be a good strategy using prime numbers in the timers to avoid coincidences with other threads competing for the same resources at the same time. Indeed the timer could not be a fixed number, it could be modified in real time as an strategy. But anyway, I can not recall any experience in which this were a real issue. Maybe in real time systems, for instance capital firms, when sending requests to a dark pool, stock market, etc. this could be an issue, but I have been working on that area and I can not recall any case in which the timers were so critical to use prime numbers, usually the big issue is the speed of the network and the buffering of requests.
And of course prime numbers would be useful if indeed you have a thread trying to locate another thread in real time and you want to avoid that, like in the case of the cicadas and their predators, in that case using prime numbers really do the work (a simulation regarding some field of Biology for instance).