Standards.JSON.encode() can stall a multi-threaded process for quite a while

Standards.JSON.encode() does not release the interpreter lock for the duration of the encoding unless the encoded value contains objects.

Add calls to check_threads_etc() at appropriate places.