(String argv[])
| 24 | } |
| 25 | |
| 26 | public static void main(String argv[]) { |
| 27 | int max = 20; |
| 28 | int runs = 1; |
| 29 | ArrayList<Thread> threads = new ArrayList<Thread>(); |
| 30 | |
| 31 | // Provide ssh server in the process. Connect using ssh -p 2020 localhost |
| 32 | if ( new Query("exists_source(library(ssh_server))").hasSolution() ) { |
| 33 | new Query("use_module(library(ssh_server))").hasSolution(); |
| 34 | new Query("ssh_server(2020)").hasSolution(); |
| 35 | } |
| 36 | |
| 37 | new Query("consult(program)").hasSolution(); |
| 38 | |
| 39 | if ( argv.length > 0 ) |
| 40 | max = Integer.parseInt(argv[0]); |
| 41 | if ( argv.length > 1 ) |
| 42 | runs = Integer.parseInt(argv[1]); |
| 43 | |
| 44 | for (int r = 0; r < runs; r++ ) { |
| 45 | long t0 = System.currentTimeMillis(); |
| 46 | for (int i = 0; i < max; i++) { |
| 47 | Thread t = new PrologMT(i); |
| 48 | t.start(); |
| 49 | threads.add(t); |
| 50 | } |
| 51 | long t1 = System.currentTimeMillis()-t0; |
| 52 | System.out.println("Created "+max+" threads in "+t1+"ms; waiting (pid="+pid()+") ..."); |
| 53 | for (int i = 0; i < threads.size(); i++) |
| 54 | { try { |
| 55 | threads.get(i).join(); |
| 56 | } catch(Exception e) { |
| 57 | System.out.println("Join failed"); |
| 58 | } |
| 59 | } |
| 60 | long t2 = System.currentTimeMillis()-t0; |
| 61 | System.out.println("All done in "+t2+"ms"); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** Run a Java thread with a Prolog engine attached during the life time |
| 66 | * of the thread. The thread must call Prolog.destroy_engine() before |
nothing calls this directly
no test coverage detected