Lock access to task->threadid

(cherry picked from commit 234ad2d0)
81 jobs for !5178 with 2739-threadsanitizer-data-race-lib-isc-task-c-435-in-task_send-unprotected-access-to-task-threadid-v9_16 in 18 minutes and 32 seconds (queued for 13 seconds)
latest merge request