OpenersNotesSection(Spacer1)Details

By default, MathLink link objects are not thread-safe. To enable thread-safety for all link objects produced by a MathLink environment object by default, set the thread-safety parameter with MLSetThreadSafeLinksParameter().

Thread-safety for link objects means that multiple threads can call MathLink API functions on the same link object simultaneously.

p must have been created using the (NonWLLink[MLNewParameters(), paclet:/ref/c/MLNewParameters]) MathLink API function.

MLSetThreadSafeLinksParameter() returns error codes using the standard error values as returned by (NonWLLink[MLError(), paclet:/ref/c/MLError]).

MLSetThreadSafeLinksParameter() is declared in the MathLink header file (RefLink[mathlink.h, paclet:/ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

int main()
{
	MLEnvironmentParameter ep;
	MLENV env;
	long apiResult;
	
	ep = MLNewParameters(MLREVISION, MLAPIREVISION);
	if(ep == (MLEnvironmentParameter)0)
	{ /* Unable to create the MLEnvironmentParameter object. */ }

	apiResult = MLSetThreadSafeLinksParameter(ep);
	if(apiResult != MLEOK)
	{ /* Failed to set thread-safe links parameter */ }

	env = MLInitialize(ep);
	if(env == (MLENV)0)
	{ /* Failed to initialize MathLInk environment object */ }

	MLReleaseParameters(ep);

	/* ... */

	MLDeinitialize(env);

	return 0;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLNewParameters(), paclet:/ref/c/MLNewParameters])  ▪  (NonWLLink[MLReleaseParameters(), paclet:/ref/c/MLReleaseParameters])  ▪  (NonWLLink[MLInitialize(), paclet:/ref/c/MLInitialize])}})}})