/* Author: Julie Romm * Course: COM3336 * Professor: Karl Lieberherr * Homework 3, part 2 */ /* File: ConcurrentThread.java * Classes implemented: ConcurrentThread * * Purpose: * This class is used for executing two threads concurrently. * The threads for execution are passed to the constructor. */ import java.io.*; import java.util.*; public class ConcurrentThread extends Thread { private TimeOutThread timeoutthread; private URLThread urlthread; private boolean status = false; public ConcurrentThread(URLThread urlthread, TimeOutThread timeoutthread) { //System.out.println("ConcurrentThread constructor start"); this.urlthread = urlthread; this.timeoutthread = timeoutthread; //System.out.println("ConcurrentThread constructor finish"); } public boolean getStatus() { return status; } public void run() { //System.out.println("ConcurrentThread: calling repeatthread.start()"); urlthread.start(); //System.out.println("ConcurrentThread: calling timeoutthread.start()"); timeoutthread.start(); try { timeoutthread.join(); urlthread.join(); } catch (InterruptedException e){}; status = timeoutthread.getStatus(); } }