Isn’t Java doing things asynchronously?

I'm trying to learn Java. I'm reading a tutorial that says:

while (N <= 0) {
           TextIO.put("The starting point must be positive. Please try again: ");
           N = TextIO.getlnInt();
        }

Looks like when you ask a user for input, it pauses until a response is received? I'm used to what happens asynchronously Is this normal for Java? Or can you do both?

thank you.

Solution

I'm not familiar with the TEXTIO library, but I'm calling InputStream Read(), i.e. using system in. When read(), it blocks until input data is available This synchronizes it

You can avoid this by using another thread to capture input (even if it is asynchronous)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>