package com.example;
import java.io.FileInputStream;
import java.io.IOException;
public class MultiThread {
public static void main(String[] args) throws Exception
{
final FileInputStream fis = new FileInputStream("d:/test/test.txt");
Thread th1 = new Thread(new Runnable() {
@Override
public void run() {
try {
int content = fis.read();
while(content != -1)
{
System.out.println(content);
content = fis.read();
}
} catch (IOException e) {
e.printStackTrace();
}
}
});
Thread th2 = new Thread( new Runnable() {
@Override
public void run() {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
});
th2.run();
th1.run();
}
}