### The java::lock Command

### Usage:

  java::lock javaObj

  The java::lock command prevents the Java object, javaObj, from getting garbage collected. A Tcl variable that references a Java object has an internal rep that points to the Java object. If the Tcl variable's internal rep is changed (e.g. to a Tcl List), the pointer to the Java Object is removed, and the Java object is garbage collected. The java::lock maintains a copy of javaObj's internal rep, so the Java object will be preserved. Multiple locks can be placed on the same Java object. If javaObject is not a valid reference to a Java object, a Tcl error is generated. It is important to note that use of the java::lock command is optional and is not required. A Java object handle that is stored in a Tcl variable will not be garbage collected until the Tcl variable is unset.

    Copyright © 1997-1998 Sun Microsystems, Inc.