Initializing help system before first use

jvmattachthread

jvmattachthread


Purpose
Persistently attach the current thread to the Java virtual machine
Synopsis
procedure jvmattachthread
Further information
1. Normally, each call to a Java function will take place in its own Java thread. For efficiency, and to enable data-sharing using ThreadLocal values, every Java call between jvmattachthread and jvmdetachthread from the system thread executing the model, will take place in the same Java thread.
2. When the parallel solver is used, solver callbacks may invoke Mosel procedures from the same model in a different system thread. Each Java call from such a callback will take place in its own Java thread, unless you call jvmattachthread from the callback itself.
3. When using jvmattachthread, you must call jvmdetachthread to explicitly detach the thread from the JVM before the end of the model. If you do not call jvmdetachthread, the Java thread will persist until the JVM is unloaded. You will see a warning written to the model's error stream if you forget to do this.
4. Calling jvmattachthread multiple times from the same system thread is supported. You must call jvmdetachthread a corresponding number of times.
5. If mosjvm has not yet loaded the Java Virtual Machine into the Mosel process, it will be loaded by this function. If Java cannot be found or an error occurs loading it, the model will terminate with a runtime error.
Related topics