I am processing a File in java where i am counting the number of occurrences of a particular Filed in every line of that file Where i am starting a Thread for every Line
as shown below
input = new BufferedReader(new FileReader(new File(finaName)));
String line = null;
while ((line = input.readLine()) != null) {
FileThread t = new FileThread(line);
t.start();
}
FileThread st = new FileThread();
System.out.println("Size"+st.list.size());
FileThread.java
public class FileThread extends Thread
List<String> list = new ArrayList<String>();
public FileThread(){}
public FileThread(String line){}
private String line = null;
public void run() {
String[] tokens = line.split("\\|", LIST.length);
String Symbol = null;
try {
Symbol = tokens[4];
list.add(symbol);
} catch (Throwable t1) {
t1.printStackTrace();
}
}
The problem is that i am always getting the Size as 0 .
please see the sample output
BIM!A
BIM!B
BIM!C
BIM!D
Size0
I have made some changes in your code, that may help you