Skip to content

Commit

Permalink
Merge pull request #562 from morris821028/master
Browse files Browse the repository at this point in the history
Example: fix hung on exit with 'status' option
  • Loading branch information
mattirn committed Aug 29, 2020
2 parents fdc2fb5 + 992587a commit e7eb5e0
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 e7eb5e0

Please sign in to comment.