@Override
	public void run() {
		isRunning = true;

		long start = System.currentTimeMillis();
		//		ArrayList<File> documents = new ArrayList<>();
		//		String path = ApplicationSetup.getInstance().getTopicFilePath();
		//		System.out.println("Reading directory: " + path);
		//		Reader reader = new Reader(path);
		//
		//		// stores all files in the arrayList
		//		reader.readFiles(documents);

		ApplicationStatus.getInstance().clear();
		
		PipedWriter inputFileWriter = null;
		BufferedReader br=null;
		try {
			inputFileWriter = new PipedWriter();

			init(inputFileWriter);

			String line;
			String[] tokens;

			boolean firstBlankLineFound=false;
			String pathString=ApplicationSetup.getInstance().getTopicFilePath()+"/topic"+topic;

			File file = new File(pathString);
			//System.out.println(path);
			//=path.toFile(); 



			//reading file and passing tokens to next pipe stages
			br = new BufferedReader(new FileReader(file));
			firstBlankLineFound = false;

			while ((line = br.readLine()) != null) {
				//				if ((line.isEmpty() || line.trim().equals("")
				//						|| line.trim().equals("\n"))){
				//					firstBlankLineFound = true;
				//				}
				//
				//				if(firstBlankLineFound){
				tokens = line.split("\\s");
				for (int i = 0; i < tokens.length; i++) {
					inputFileWriter.write(tokens[i] + "\n");
					inputFileWriter.flush();
				}
				//				}
			}



		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			try {

				if(br!=null){
					br.close();
				}
				if (inputFileWriter != null)
					inputFileWriter.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}



			long end = System.currentTimeMillis();
			System.out.println("reading files DONE in ");
			System.out.println((end - start) / 1000 + " seconds");


			try {
				Thread.sleep(200);
			} catch (InterruptedException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}


			ApplicationStatus.getInstance().doRanking();
			System.out.println("ranking computation complete!");
			ApplicationStatus.getInstance().printResults();

			isRunning = false;

			try {
				pool.awaitTermination(2000, TimeUnit.MILLISECONDS);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}