Skip to content

Commit

Permalink
Example: fix hung on exit with 'status' option
Browse files Browse the repository at this point in the history
  • Loading branch information
morris821028 committed Aug 19, 2020
1 parent fdc2fb5 commit 992587a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions builtins/src/test/java/org/jline/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,24 @@ public static void main(String[] args) throws IOException {
case "status":
completer = new StringsCompleter("foo", "bar", "baz");
callbacks.add(reader -> {
new Thread(() -> {
Thread thread = new Thread(() -> {
int counter = 0;
while (true) {
try {
Status status = Status.getStatus(reader.getTerminal());
counter++;
status.update(Arrays.asList(new AttributedStringBuilder().append("counter: " + counter).toAttributedString()));
status.update(Arrays.asList(new AttributedStringBuilder()
.append("counter: " + counter)
.toAttributedString()));
((LineReaderImpl) reader).redisplay();
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
});
thread.setDaemon(true);
thread.start();
});
break;
case "argument":
Expand Down

0 comments on commit 992587a

Please sign in to comment.