There is a function to read from the file:
private static String read(File in) { String result= ""; try ( BufferedReader reader = new BufferedReader(new FileReader(in))) { while (reader.ready()) { result= reader.readLine() + "\n"; } } catch(FileNotFoundException e) { System.out.println("File Not Found"); } catch (IOException e) { e.printStackTrace(); } return result; } The file is a matrix:
1 2 3 4 5 6 7 8 9 0 When reading, I crush the file by "\n" it takes one line and writes to result , then I call this function in the stream that is responsible for reading:
Thread t_1 = new Thread(new Runnable() { @Override public void run() { str = read(new File("FileName.csv")); } }); t_1.start(); How can I make the first line read, the result is written to str , and the line goes to another thread for processing, and the first thread starts reading the second line from the file? Just now it turns out that the last line of the file is fed into str .