public class PiTest{ public static void main(String[] args) { double pi=0.0; for(double i=1.0;i<1000000001d;i++){ pi += Math.pow(-1,i+1)/(2*i-1); } System.out.println(4*pi); }}
import com.fourinone.BeanCoNtext;public class ParkServerDemo{ public static void main(String[] args) { BeanCoNtext.s tartPark(); }}
// PiWorker
import com.fourinone.MigrantWorker;import com.fourinone.WareHouse;public class PiWorker extends MigrantWorker{ public double m=0.0,n=0.0; public PiWorker(double m, double n){ this.m = m; this.n = n; } public WareHouse doTask(WareHouse inhouse) { double pi=0.0; for(double i=m;i<n;i++){ pi += Math.pow(-1,i+1)/(2*i-1); } System.out.println(4*pi); inhouse.setObj("pi",4*pi); return inhouse; } public static void main(String[] args) { PiWorker mw = new PiWorker(Double.parseDouble(args[2]),Double.parseDouble(args [3])); mw.waitWorking(args[0],Integer.parseInt(args[1]),"PiWorker"); }}
// PiCtor
import com.fourinone.Contractor;import com.fourinone.WareHouse;import com.fourinone.WorkerLocal;import java.util.Date;public class PiCtor extends Contractor{ public WareHouse giveTask(WareHouse inhouse) { WorkerLocal[] wks = getWaitingWorkers("PiWorker"); System.out.println("wks.length:"+wks.length); WareHouse[] hmarr = doTaskBatch(wks, inhouse); double pi=0.0; for(WareHouse result:hmarr){ pi = pi + (Double)result.getObj("pi"); } System.out.println("pi:"+pi); return inhouse; } public static void main(String[] args) { PiCtor a = new PiCtor(); long begin = (new Date()).getTime(); a.giveTask(new Wa reHouse()); long end = (new Date()).getTime(); System.out.println("time:"+(end-begin)/1000+"s"); a.exit(); }}