ThreadSafe
Perangkap Thread-Safe dalam Pemrosesan XML – Beragampengetahuan
Apakah menurut Anda metodenya children() Berikut ini adalah keamanan utas? import java.util.stream.Stream; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public final class SafeXml { private final Node node; SafeXml(final Node node) { this.node = node.cloneNode(true); } public Stream<SafeXml> children() { NodeList nodes = this.node.getChildNodes(); int length = nodes.getLength(); return Stream.iterate(0, idx -> idx + 1) .limit(length) .map(nodes::item) .map(SafeXml::new); […]