|
import java.util.ArrayList;
import java.util.List;
public class TestThread {
static List<Prameter> prameterList = new ArrayList<Prameter>();
static {
for(int i=0;i<10;i++){
prameterList.add(new Prameter("a"+i,"b"+i));
}
}
/**
* @param args
*/
public static void main(String[] args) {
for(int i=0;i<10;i++){
new MyThread(i,prameterList.get(i)).start();
}
}
}
class Prameter {
private String a;
private String b;
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public Prameter(String a, String b) {
super();
this.a = a;
this.b = b;
}
}
class MyThread extends Thread{
private int i;
private Prameter prameter;
public MyThread (int i,Prameter prameter){
this.i = i;
this.prameter = prameter;
System.out.println(this.getName()+" inited.");
}
public void run(){
try {
this.sleep(10*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
long startTime = System.currentTimeMillis();
this.processTest();
long endTime = System.currentTimeMillis();
System.out.println(this.getName()+" Thread Run time:"+(endTime-startTime)+" ms");
}
private void processTest(){
new Client().test(this.prameter.getA()+" -> "+ this.prameter.getB());
}
}
class Client {
public void test(String s){
System.out.println(s);
}
} |
|