All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.omnidial.harvest.ThreadedDialCandidateHarvester Maven / Gradle / Ivy

The newest version!
package org.omnidial.harvest;

import java.util.ArrayList;

public abstract class ThreadedDialCandidateHarvester extends DialCandidateHarvester implements Runnable {

	ArrayList threads = new ArrayList();

	@Override
	public void getCandidatesForNumber(String dialedNumber,
			String e164Number) {

		createThreads(dialedNumber, e164Number);
		
		new Thread(this).start();
	}

	@Override
	public void run() {
		for(Thread t : threads) {
			while(t.isAlive()) {
				try {
					t.join();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		onHarvestCompletion();	
	}
	
	protected void addThread(Thread t) {
		threads.add(t);
	}

	protected abstract void createThreads(String dialedNumber,
			String e164Number);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy