paket com.cooly;import java.util.LinkedList;/*** @author coolyqq*Mensimulasikan pencetakan antrian printer pencetakan*Kelas distribusi*/kelas publik DataDistribute {private static DataDistribute instance = null;private final static byte[] obj = new byte[0];//Mekanisme kunci private LinkedList<DataDistributeEntity> tugas = null;//Tugas distribusi private boolean isColse = true;private DataDistribute() {tugas = new LinkedList<DataDistributeEntity>();}/*** @return* Dapatkan instance*/public static DataDistribute getInstance(){if(instance == null){disinkronkan (obj) {if(instance == null) {instance = new DataDistribute();}}}return instance ;}/*** @param entitas* Tambahkan tugas*/public void addTask(DataDistributeEntity entitas){disinkronkan (obj) {tasks.add(entity);}}/*** @param entitas* Tambahkan tugas segera*/public void addSpeedTask(DataDistributeEntity entitas){disinkronkan (obj) {tasks.addFirst(entitas); }}mulai kekosongan publik(ICallBack callback){if(tasks==null||tasks.isEmpty()||!this.isColse){return;}else{this.isColse = false;} while(true){DataDistributeEntity entitas = tugas.poll(); if(entitas==null){ini.isColse = true;break;}callback.call(entity);tasks.remove(entity);}System.out.println("fsf");}public boolean isColse() {return isColse;}public void setColse(boolean isColse) { ini.isColse = isColse;}}