Check for query.thread before making changes to thread cache.