Advertisement
logicmoo

Is now isolated and unshared predicate

Dec 6th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.72 KB | None | 0 0
  1. Thread t = new Thread() {
  2.   @Override
  3.   public void run() {
  4.     Query query = new Query("thread_local(x/0)");
  5.     query.hasSolution();
  6.     System.out.println("Is now isolated and unshared predicate"); //query succeeds
  7.   }
  8. };
  9.  
  10. t.start();
  11. t.join();
  12.  
  13.  
  14. t = new Thread() {
  15.   @Override
  16.   public void run() {
  17.     Query query = new Query("assert(x)");
  18.     query.hasSolution();
  19.     query = new Query("x");
  20.     System.out.println("Thread1 x:" + query.hasSolution()); //query succeeds
  21.   }
  22. };
  23. t.start();
  24. t.join();
  25.  
  26. t = new Thread() {
  27.   @Override
  28.   public void run() {
  29.     Query query = new Query("x");
  30.     System.out.println("Thread2 x:" + query.hasSolution()); //query also succeeds
  31.   }
  32. };
  33. t.start();
  34. t.join();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement