I am trying this program in java but I am not getting any output when I put everything in the run() method
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());
}
}
Test.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);
}
}
What I want to do is that I want to read lines from a file using two threads and then display whatever I get . I am new to Java
EDIT :
I was not using the start() method. Though even after using start() It reads only 2 lines from the file and stops. What could be the problem
?