1

I am writing a shell program in java, where it prompts to my user to enter input (i.e. "Prompt: ")

However separate threads that monitor activity also print to the shell, ex: "Client Connected!"

Any ideas/tips on how to make this a more user-friendly environment, where input from the user preceding a return would not be interrupted by a system message, but still allowing the message to display?

Gagan Singh
  • 988
  • 12
  • 22
  • 1
    both your requirements and your progress/attempts so far are unclear... – mfsiega Oct 14 '12 at 17:58
  • You would need to design/implement a producer/consumer setup where the thread that takes user input also consumes then outputs the messages produced by your other threads. Or, pause your other threads while waiting for user input. Or ... a couple of other approaches. This is a fairly broad question. – Brian Roach Oct 14 '12 at 18:01

1 Answers1

0

Typical console applications print information to screen sequentially. Programs the print information while waiting response to user are interactive program that usually control where and how do they print information. As an example you can see how top works on Unix.

There is a way to implement such kind of applications in java. You have to implement escape sequences for each supported terminal, so that you can control where and how to print each character. Fortunately there is such library that already does this.

See for example this discussion: What's a good Java, curses-like, library for terminal applications?

Community
  • 1
  • 1
AlexR
  • 114,158
  • 16
  • 130
  • 208