以下のような DOM ドキュメントの静的オブジェクトを作成しました。これは、javax.xml.parsers.* および org.w3c.dom.* API を使用します。
DocumentBuilderFactory docBldrFactry = DocumentBuilderFactory.newInstance();
docBldrObj = docBldrFactry.newDocumentBuilder();
File file = new File(fileDirectory);
// Parse the XML file and return a DOM document object
document = docBldrObj.parse(file);
//FYI, document is declared as private static org.w3c.dom.Document document elsewhere.
上記で作成した後で、この静的 DOM ドキュメント オブジェクトがスレッドによって共有されているが、すべてのスレッドがこのドキュメントを読み取る (トラバースする) だけの場合、それはスレッド セーフですか?
read はこの共有状態を変更すべきではないためだと思いますが、内部的に私が知らない魔法があるかどうかはわかりません。
ありがとう