Skip to content

Instantly share code, notes, and snippets.

@colin-haber
Created May 29, 2011 17:02
Show Gist options
  • Select an option

  • Save colin-haber/997953 to your computer and use it in GitHub Desktop.

Select an option

Save colin-haber/997953 to your computer and use it in GitHub Desktop.
Print Queue Handler
private void runPrinter() {
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
if (!JConsolePane.this.messages.isEmpty()) {
JConsolePane.this.print(JConsolePane.this.messages.get(0));
JConsolePane.this.messages.remove(0);
}
}
}
}).start();
}
@colin-haber
Copy link
Copy Markdown
Author

This runs after everything is initialized and is called last in the constructor. All print() methods other than print(Message) add a new Message to messages, an ArrayList of messages. But it seems to not work. See it in context at https://github.com/dgn1nja/JavaCon/blob/master/com/n1nja/javacon/JConsolePane.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment