Buffer threadsafety with lock(q){}