*/
public void run() {
long minSleepTime = 15000;
long sleepTime = 2000;
HashPrintServiceAttributeSet attrs;
PrintServiceAttributeEvent attrEvent;
PrintServiceAttributeListener listener;
PrintServiceAttributeSet psa;
while (!stop) {
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
}
synchronized (this) {
if (listeners == null) {
continue;
}
long startTime = System.currentTimeMillis();
if (listeners != null) {
if (service instanceof AttributeUpdater) {
psa =
((AttributeUpdater)service).getUpdatedAttributes();
} else {
psa = service.getAttributes();
}
if (psa != null && !psa.isEmpty()) {
for (int i = 0; i < listeners.size() ; i++) {
listener = (PrintServiceAttributeListener)
listeners.elementAt(i);
attrs =
new HashPrintServiceAttributeSet(psa);
attrEvent =
new PrintServiceAttributeEvent(service, attrs);
listener.attributeUpdate(attrEvent);
}
}