Created
August 10, 2019 20:09
-
-
Save Vzor-/68f3e6759b4e45071a8bb36735062a8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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