public void run() { String filename = "flipper.xml"; try { DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); XMLDocumentManager docMgr = client.newXMLDocumentManager(); for (int i = 1; i <= 15; i++) { System.out.println("Writing document " + i + " from: " + msg); // write docs String docId = "/multithread-write/filename" + i + ".xml"; docMgr.write(docId, new FileHandle().with(file)); Random rand = new Random(); int r = rand.nextInt(2000) + 1000; try { Thread.sleep(r); } catch (InterruptedException e) { e.printStackTrace(); } } // release client client.release(); } catch (KeyManagementException | NoSuchAlgorithmException | IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }