Avoid sharing script objects or script arrays across threads (this includes global.) Sharing script objects is asking for trouble. Share only primitive data types, or Java objects.
This is a list of 10 best practices that are more subtle than your average Josh Bloch Effective Java rule. While Josh Bloch's list is very easy to learn and concerns everyday situations, this list here contains less common situations involving API / SPI design that may have a big effect nontheless. I have encountered…
// create the JAXP XPath evaluation environment.
XPath xpath = XPathFactory.newInstance().newXPath();
// creat an xpath expression. This example select all nodes with the
// name 'link' from the root of the document.
String expression = "//link";
// get a list of nodes using the xpath environment, DOM Document and the
// XPath expression. Specify the type of node that is retrived (in this
// case its a NODESET which is a list of nodes)
NodeList linkNodes = (NodeList) xpath.evaluate(expression, bbcDoc, XPathConstants.NODESET);
for (int i = 0; i < linkNodes.getLength(); i++) {
// System.out.println(linkNodes.item(i).getTextContent());
}
J. Broekstra, A. Kampman, und F. van Harmelen. Proceedings of the first International Semantic Web
Conference (ISWC 2002), 2342, Seite 54--68. Sardinia, Italy, Springer Verlag, Heidelberg Germany, (Juni 2002)See also http://www.openrdf.org/.