KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Interleave


1 import jcifs.smb.*;
2
3 public class Interleave {
4
5     static class IThread extends Thread JavaDoc {
6         String JavaDoc url;
7
8         IThread( String JavaDoc url ) {
9             this.url = url;
10         }
11
12         public void run() {
13             try {
14                 yield();
15                 System.out.println( getName() + ": started" );
16                 SmbFileOutputStream o = new SmbFileOutputStream( url );
17                 o.close();
18                 System.out.println( getName() + ": done" );
19             } catch( Exception JavaDoc x ) {
20                 x.printStackTrace();
21             }
22         }
23     }
24
25     public static void main(String JavaDoc[] argv) throws Exception JavaDoc {
26         if( argv.length < 2 ) {
27             System.out.println( "java Interleave dir numThreads" );
28             return;
29         }
30     
31         int numThreads = Integer.parseInt( argv[1] );
32         IThread[] t = new IThread[numThreads];
33         for( int i = 0; i < numThreads; i++ ) {
34             t[i] = new IThread( argv[0] + "/it" + i + ".tmp" );
35         }
36         for( int j = 0; j < numThreads; j++ ) {
37             t[j].start();
38         }
39     }
40 }
41
Popular Tags