多线程的问题,请帮帮我
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import
java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
public class Alexa implements Runnable {
public ArrayList s = new ArrayList();
public static void main(String[] args) throws
IOException {
Alexa alexa = new Alexa();
alexa.readFile( "c:\\sss.txt ");
Thread t = new Thread(alexa);
t.start();
}
public void run() {
String a = " ";
for (int i = 0; i < s.size(); i++) {
a = (String) s.get(i);
try {
saveBinaryFile(a);
System.out.println( "i= " + i);
System.out.println( "a= " + a);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void saveBinaryFile(String url1) throws IOException {
BufferedInputStream in = null;
OutputStream out = null;
try {
URL url = new URL(url1);
URLConnection conn = url.openConnection();
in = new BufferedInputStream(conn.getInputStream());
out = new FileOutputStream(new File( "c://tmp// "
+ System.currentTimeMillis()));
int n = 0;
byte[] bytes = new byte[1024];
while ((n = in.read(bytes)) != -1) {
out.write(bytes, 0, n);
}
} catch (Exception e) {
} finally {
try {
in.close();
out.close();
} catch (Exception ioe) {
ioe.getStackTrace();
}
}
}
public void readFile(String path) {
String fileline;
ArrayList domains = new ArrayList();
try {
BufferedReader d = new BufferedReader(new FileReader(path));
while ((fileline = d.readLine()) != null) {
domains.add(fileline);
System.out.println(fileline);
}
} catch (Exception e) {
System.out.println( "readFile.Error: " + e.getMessage() + " "
+ e.getClass());
e.printStackTrace();
} finally {
try {
} catch (Exception e) {
}
}
s = domains;
}