class ThreadX extends Thread{
public void run()
{ }
}
スレッドの実行:
Thread t=new ThreadX;
t.start();
class test {
public static void main(String args[]) {
Write pw = new Write();
pw.start();
}
}
class Write extends Thread {
public void run() {
try {
for(int count = 0 ; count < 10 ; count++) {
System.out.println("hello");
Thread.sleep(1000);
}
}
catch (InterruptedException err) {
System.out.println(err);
}
}
}
try {
FileInputStream in =new FileInputStream("ex.java");
int size=in.available();//ファイルのバイト数
byte barray[] = new byte[size];
int size1=in.read(barray);
System.out.println("copy size:"+size+":"+size1);
FileOutputStream out=new FileOutputStream("ex.txt");
out.write(barray);//配列のサイズだけ記録する
out.close();
}
catch (IOException ex){
System.out.println("io-error:"+ex.getMessage());
}