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

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

Step by Step Solution

3.56 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer Here is the code to read the 2 files in 2 separate thre... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!