Develop a java program using multithreading in which each thread reads the data from a text file
Question:
Develop a java program using multithreading in which each thread reads the data from a text file and display the data of each file on Console alternatively such that one line from first input file is printed and then one line from another input file is printed and so on.
Detailed Description:
You are required to develop a java program containing two threads that reads two files simultaneously.In a program, first thread reads data from file “Personal_Record.txt” and second thread reads the data from file “Academic_Record.txt”.
When one thread reads a line from one file then it should allow another thread to read a line from another file.
After reading data from each file, program must write the output on console (Output screen) such that one line from first input file is printed and then one line from another input file is printed and so on.Sample Output
First Input file
Personal_Record.txt
STD01 Saqib 18 STD02 Kashif 17 STD03 Memoona 19 STD04 Madiha 18 STD05 Sidra 18 STD06 Hina 17 STD07 Shahid 19 STD08 Huma 18 STD09 Saeeda 17 STD10 Anjum 18 |
Statistics The Art and Science of Learning from Data
ISBN: 978-0321755940
3rd edition
Authors: Alan Agresti, Christine A. Franklin