| 1 5 package org.h2.test.synth; 6 7 import java.sql.Connection ; 8 import java.sql.DriverManager ; 9 import java.sql.SQLException ; 10 import org.h2.test.TestBase; 11 12 public class TestMulti extends TestBase { 13 14 public volatile boolean stop; 15 16 public void test() throws Exception { 17 Class.forName("org.h2.Driver"); 18 deleteDb(BASE_DIR, "openClose"); 19 20 int len = 10; 22 TestMultiThread[] threads = new TestMultiThread[len]; 23 for(int i=0; i<len; i++) { 24 threads[i] = new TestMultiNews(this); 25 } 26 threads[0].first(); 27 for(int i=0; i<len; i++) { 28 threads[i].start(); 29 } 30 Thread.sleep(10000); 31 this.stop = true; 32 for(int i=0; i<len; i++) { 33 threads[i].join(); 34 } 35 threads[0].finalTest(); 36 } 37 38 public Connection getConnection() throws SQLException { 39 final String url = "jdbc:h2:"+BASE_DIR+"/openClose;LOCK_MODE=3;DB_CLOSE_DELAY=-1"; 40 Connection conn = DriverManager.getConnection(url, "sa", ""); 41 return conn; 42 } 43 44 45 } 46 | Popular Tags |