KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > test > synth > TestMulti


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.test.synth;
6
7 import java.sql.Connection JavaDoc;
8 import java.sql.DriverManager JavaDoc;
9 import java.sql.SQLException JavaDoc;
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 JavaDoc {
17         Class.forName("org.h2.Driver");
18         deleteDb(BASE_DIR, "openClose");
19
20 // int len = getSize(5, 100);
21
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 JavaDoc getConnection() throws SQLException JavaDoc {
39         final String JavaDoc url = "jdbc:h2:"+BASE_DIR+"/openClose;LOCK_MODE=3;DB_CLOSE_DELAY=-1";
40         Connection JavaDoc conn = DriverManager.getConnection(url, "sa", "");
41         return conn;
42     }
43     
44
45 }
46
Popular Tags