Skip to content

Instantly share code, notes, and snippets.

@Vzor-
Created August 10, 2019 20:09
Show Gist options
  • Save Vzor-/68f3e6759b4e45071a8bb36735062a8a to your computer and use it in GitHub Desktop.
Save Vzor-/68f3e6759b4e45071a8bb36735062a8a to your computer and use it in GitHub Desktop.
import sun.awt.AppContext;
import javax.print.PrintServiceLookup;
import java.util.Set;
public class Main {
public static void main(String[] args) {
int count = 0;
while (true) {
count++;
long time1 = System.currentTimeMillis();
Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
for(Thread thread : threadSet){
if(thread.getName().equals("PrinterListener")){
thread.interrupt();
}
}
AppContext.getAppContext().put(PrintServiceLookup.class.getDeclaredClasses()[0], null);
PrintServiceLookup.lookupPrintServices(null, null);
long time2 = System.currentTimeMillis();
System.out.println("Try #" + count + " delta time " + (time2 - time1) + " ms");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment