There is a list of tasks. Denoted as a task and runtime. Time is relative. That is, if it is indicated that the first task should be launched on January 1, 2016 13: 50: 10,456, and the second one on January 1, 2016 13: 50: 10,496, then the first task will be started at the current time, and the second should start after 40 ms.
I already broke my head how to do it.
It is clear that each task must be run in a separate thread. The problem is that creating a stream also takes time, and the intervals between tasks can be 1 ms. In this case, I can not afford to lose even 1 ms.
There was an idea to start the threads in advance, and loop the loop in them (or turn on the timer) to start the task, but the task list can have tens of thousands of tasks.