TAILOR: v_1.0 Tailor is a java library used to execute threads in a batch system. Programmer can keep adding threads to queue and call 'notifyExecutioner', this will batch the threads and will execute.
Importing the Tailor Library.
-
Import the class 'Bobbin'
-
Create an instance of Bobbin, Bobbin is a singleton, Bobbin b = Bobbin.getInstance();
-
use 'b.add();' to add threads to the queue.
-
After addding threads call notifyExecutioner() from the class Bobbin. It takes an interface 'ExecutionListener' as a parameter. Ex :
b.notifyExecutioner(new ExecutionListener(){ @Override public void executionCompleted(int count,int totalCount) { System.out.println("exec count "+count+" : total count is "+totalCount); } });
The executionCompleted(int count,int totalCount) method of 'ExecutionListener' is called after executing one batch.
Methods in Bobbin to use,
- setExecLimit(int limit)
- getExecLimit() - returns an integer
- add(Thread thread)
- add(ArrayList threadListParam,ExecutionListener executionListener) , if you call this method you dont have to call 'notifyExecutioner()'. Automatically the list of threads will be added to queue, and will be executed accordingly.