Pass queue to threads instead of making it global