Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Taking input in Java without program hanging?

I was just wondering how i would let my java program continue running, but always be ready to take input.

Right now i am using a bufferreader and reading in a line, but that makes my program halt and wait for input. I want the program to continue running but be ready to take input whenever needed, is there a way to do this?

like image 364
Petey B Avatar asked Jan 30 '26 01:01

Petey B


1 Answers

I would expect that you're going to have to look into multithreading your application in order to get this working as you desire.

Edit: Of course, while this functionality can be achieved by a purely CLI interface, you would probably be better off exploring other options (i.e. GUI options) if you intend on having a full response/event-driven system running in a multithreaded fashion.

like image 116
James B Avatar answered Jan 31 '26 15:01

James B