AssignmentView more random threads:
- Assignment No. 01 Semester: Spring 2012 CS609: System...
- CS614 Data Warehousing Assignment No. 1 31st Fall Semester...
- CS402 Theory of Automata assignment no 1 spring fall...
- CS504 Software Engineering-1Assignment no 2 Fall 16...
- CS614 Data Warehousing Assignment No. 03 Semester Spring...
- CS607 Assignment No 3 Solution
- need cs501 3rd assignment idea
- cs501 Assignment no 3 Solution 20th January 2016
- Software Project Management assignment no 1 fall 2011...
- CS614 Data Warehousing Assignment No.1 Solution &...
Problem Statement:
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 with three classes containing two classes “FirstThread” and “SecondThread” extended from Thread class. MainThread class is your derive class. Thread classes read two files simultaneously.
FirstThread firstThread = new FirstThread("first.txt");
SecondThread secondThread = new SecondThread("second.txt");
In a program, first thread reads data from file “first.txt” and second thread reads the data from file “second.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.
Use Thread.sleep()method with random parameter range of 1000;
Sample Output
First Input file
first.txt
1
2
3
4
5
6
7
8
9
10
File1.txt
Second Input file
second.txt
1
2
3
4
5
6
7
8
9
10
Output of program
Sponsored Links
Note: sequence of output may change due to sleep function of thread
There are currently 1 users browsing this thread. (0 members and 1 guests)