According to
http://jena.apache.org/documentation/tdb/tdb_transactions.html#multi-threaded-use

only one DataSet connection can be used per Java thread. However, I need
several connections to (different) data models within a single application.
I noticed that if one tries to use several datasets per single-thread then
the application is blocked when trying to create the second dataset. I
tried to overcome the issue by creating a new thread per dataset (just as
recommended in the Jena documentation). However, the problem is still the
same: The second "TDB.createDataset(..)" statement causes the application
to be blocked.

This is my (runnable) test code:

JunitTest:

public static void main(String[] args) {
   String dir
= "/Users/andreas_gruenwald/da-agr/resources/design/jena_tdb/itpm_jena";
   Runnable tdb1 = new TDBThread(dir, null);
   Runnable tdb2 = new TDBThread(dir, null);
   tdb1.run();
   tdb2.run();
   System.out.println("Finished");
}


TDBThread.java:

public class TDBThread implements Runnable {
   private Dataset tdbDataSet;
   private String directory;

public TDBThread(String directory) {
   tdbDataSet = null;
   this.directory = directory;
}

@Override
public void run() {
   System.out.println(String.format("Run (directory=%s)...", directory));
   *tdbDataSet** = TDBFactory.createDataset(directory); //blocks here*
   System.out.println("Tdbdataset is now " + tdbDataSet);
   tdbDataSet.begin(ReadWrite.WRITE); *//causes block*
}
}

Any ideas what I (or Jena) is doing wrong?

-- 
Andreas Grünwald
Tel.: +43 650 77 82340

Reply via email to