proper multithreading via triple buffering