When used in the multi-threaded engine, xsb_command_string protects the called thread from API calls from other pthreads until the command is finished.
Return Codes
When used in the multi-threaded engine, xsb_command_string does not protect the called thread from API calls from other pthreads until the command is finished. It is the user's responsibility to protect the XSB thread, using a mutex or other concurrency control, from the time the goal begins to be constructed in the register 1 until the command has completed.
Apart from the steps necessary to formulate the query and the lack of protection of the XSB thread, the behavior of xsb_command() is similar to that of xsb_command_string(), including its return codes.