"tallpsmith" wrote : 
  | Lets assume a local TreeCache with isolation Level set to Serializable.
  | 

Are you sure you set the isolation level correctly ? Did you do:

cache.setIsolationLevel(IsolationLevel.SERIALIZABLE);

or set it via XML ?

Look at the code below, works exactly as it should: thread2 has to wait for 
3secs until it can (read) access the data.


  |    public void testConcurrentReadsWithSerializableIsolationLevel() throws 
CacheException, InterruptedException {
  |       final long TIMEOUT=5000;
  |       cache.setIsolationLevel(IsolationLevel.SERIALIZABLE);
  |       cache.put("/testfqn", "testkey", "testvalue"); // add initial value, 
to be read by threads
  |       Reader r1, r2;
  |       r1=new Reader("reader1", 3000);
  |       r2=new Reader("reader2", 0);
  |       r1.start();
  |       pause(100); // make sure thread1 starts and acquires the lock before 
thread2
  |       r2.start();
  |       r1.join(TIMEOUT);
  |       r2.join(TIMEOUT);
  |    }
  | 
  |    class Reader extends Thread {
  |       long timeout;
  | 
  |       public Reader(String name, long timeout) {
  |          super(name);
  |          this.timeout=timeout;
  |       }
  | 
  |       public void run() {
  |          UserTransaction trans=null;
  |          try {
  |             trans=(UserTransaction)new 
InitialContext(p).lookup("UserTransaction");
  |             trans.begin();
  |             Object retval=null;
  |             log2("accessing tree");
  |             retval=cache.get("testfqn", "testkey");
  |             log2("retval: " + retval);
  |             if(timeout > 0) {
  |                log2("sleeping for " + timeout + " ms");
  |                pause(timeout);
  |             }
  |          }
  |          catch(Exception e) {
  |             e.printStackTrace();
  |          }
  |          finally {
  |             try {trans.commit();} catch(Throwable t) {}
  |             log2("done");
  |          }
  |       }
  |    }
  | 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3854774#3854774

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3854774


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to