Made streaming source thread safe

Critical Sections were used to prevent access to variables at the same
time.