run()
このプログラムをJavaで試していますが、メソッドにすべてを入れても出力が得られません
Main.java:
public class Main {
static int line;
static boolean ret = true;
static BufferedReader br;
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
File f = new File("tere.dat");
// boolean ret = f.createNewFile() ;
br = new BufferedReader(new FileReader(f));
new Test(br.readLine());
new Test(br.readLine());
}
}
テスト.java:
public class Test extends Thread {
private String input;
static int thread_count = 0;
public Test(String l)
{
input = l;
}
public void run()
{
System.out.println("Checking from other class : This was printed from file :>>");
System.out.println(input);
String upper = input.toUpperCase();
System.out.println("");
System.out.println("The String in all UpperCase :" + upper);
}
}
私がやりたいことは、2 つのスレッドを使用してファイルから行を読み取り、取得したものを表示したいということです。私はJavaが初めてです
編集:
start()
メソッドを使用していませんでした。使用した後でも start()
、ファイルから2行しか読み取らずに停止します。何が問題なのですか?