little update: use different functions to control the thread
add example for pp and opengl