Ever programmer knows, that programs need to be predictable. Any code that is not predictable will do something undefined and therefore most likely crash or worse. But when I tried to figure out what Java's
lazySet() method does, I came up with the idea
Is it possible to write a program that is unpredictable, yet works fine and does something useful/interesting?
So that will be your task. Do not avoid chaos, but utilize it. Whether you use the actual lazySet, thread timing, random or uninitialized variables is up to you. The following rules apply:
The code-path must be unpredictable. That is: if I would debug it, the program would take a "random" path each time.
The program must do something useful/interesting and handle all possible (unpredictable) states somehow. No crashes! (Core dumps are neither useful nor interesting!)
You are not allowed to check something in a loop till it has the desired value. You must work with whatever is stored in there and do something with it.
You can use any language, except those specifically optimized for this contest.
This is a creative question so the one with the most votes wins. Please note that programs doing common stuff like gambling, printing random numbers or generating RPG loot are too well-known to be considered interesting. Please surprise us.
Bonus points should be given for:
- The creativity of the choice/design of unpredictability (Math.random isn't that creative).
- The creativity in management of unpredictability.
- Everything genius. ;)