Chào các bạn! Vì nhiều lý do từ nay Truyen2U chính thức đổi tên là Truyen247.Pro. Mong các bạn tiếp tục ủng hộ truy cập tên miền mới này nhé! Mãi yêu... ♥

Bài 27: thread

package thread;

import java.lang.*;

import java.io.*;

//public class Thread {

public class MyThread extends Thread{

public static int nhap(String s){

String s1; int i;

System.out.print(s);

DataInputStream st=new DataInputStream(System.in);

try{

s1=st.readLine();

}catch(IOException e){s1="";}

try{

i=Integer.valueOf(s1).intValue();

}catch(NumberFormatException f){i=0;}

return i;

}

int n;

MyThread(int x){

this.n= x;

System.out.print("Thread("+this.n+")");

start();

}

public void run(){

int m,i,j;

int a[][];

a=new int[10][10];

m=nhap("m:=");

for(i=1;i<=m;i++)

    for(j=1;j<=m;j++){

    a[i][j]=nhap("a["+i+"]["+j+"]:=");

    }

}

    public static void main(String[] args) {

    int n,i;

    n=nhap("n:=");

    for(i=1;i<=n;i++){

    MyThread mt=new MyThread(i);

    }

    }

Bạn đang đọc truyện trên: Truyen247.Pro

Tags: