Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sun.awt.AppContext;
- import javax.print.PrintServiceLookup;
- public class SlowPrinting {
- // Refresh interval in seconds
- public static int CUPS_REFRESH_INTERVAL = 30;
- public static void main(String ... args) {
- int count = 0;
- long delta = 0;
- int delayCount = 0;
- while (true) {
- count++;
- long time1 = System.currentTimeMillis();
- //If either line is commented out, the program will run full speed
- if ((time1 - delta)/1000 > CUPS_REFRESH_INTERVAL) {
- delta = time1;
- delayCount++;
- System.out.println("Attempt " + delayCount + " refreshing printer listing... ");
- AppContext.getAppContext().put(PrintServiceLookup.class.getDeclaredClasses()[0], null);
- }
- PrintServiceLookup.lookupPrintServices(null, null);
- long time2 = System.currentTimeMillis();
- if (time2 - time1 > 100) {
- System.out.println((time2 - time1)/1000.0f + " delay detected on try #" + count+ ".");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement