Package com.cooly;
Import java.util.LinkedList; /** * @author COOLYQQ * Analog Print printer queued print * Distribution class * * public class Datadistribute {private static Datadistribute instance = NULL; p Rivate final static byte[] obj = new byte[0];//lock mechanism private linkedlist<datadistributeentity> tasks = null;//Distribution Task Priv
Ate Boolean iscolse = true;
Private Datadistribute () {tasks = new linkedlist<datadistributeentity> ();} /** * @return * Get instance/public static Datadistribute getinstance () {if (instance = null) {synchronized (obj) {if (in
stance = = NULL) {instance = new Datadistribute ();}}
return instance;
/** * @param entity * Add task/public void AddTask (datadistributeentity entity) {synchronized (obj) {tasks.add (entity); }/** * @param entity * Add task now/public void Addspeedtask (datadistributeentity entity) {synchronized (obj) {tasks.ad
DFirst (entity); } public void Start (Icallback callback) {if tasks==null| | Tasks.isempty () | |! This.iscolse) {return;} else{This.iscolse = false;(true) {datadistributeentity entity = Tasks.poll (); if (entity==null) {this.iscolse = true; break;} callback.call (entity); tasks
. Remove (entity);
} System.out.println ("FSF"); public Boolean Iscolse () {return iscolse.} public void Setcolse (Boolean iscolse) {this.iscolse = Iscolse;}}