Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7597373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:08:30+00:00 2026-05-30T22:08:30+00:00

2 basic questions: When you make a scanner out of System.in, and then you

  • 0

2 basic questions:

  1. When you make a scanner out of System.in, and then you write, say, “scan.nextLine()”, what is actually happening before you hit “enter”? Is the thread running the code sleeping and it is awoken only when a newline character comes in from System.in? How else would it wait for the human to type in the input?

  2. When a thread is “blocked” does that mean that it’s asleep? Or does it just mean that it can’t enter a certain piece of code, but could be doing other stuff?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:08:32+00:00Added an answer on May 30, 2026 at 10:08 pm

    At any point in time, every thread is in one thread state. The possible thread states are

    • NEW: A thread that has not yet started is in this state.
    • RUNNABLE: A thread executing in the Java virtual machine is in this state.
    • BLOCKED: A thread that is blocked waiting for a monitor lock is in this state.
    • WAITING: A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
    • TIMED_WAITING: A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
    • TERMINATED: A thread that has exited is in this state.

    The only state where a thread executes any code is the RUNNABLE state.

    Reading from System.in while there isn’t enough data available will put the thread in the BLOCKED state. There it will wait for more data to arrive, or the InputStream to close, whichever happens first (not sure if System.in can be closed, but other streams certainly can), and then become RUNNABLE again.

    Technically speaking, sleeping (TIMED_WAITING) and blocking (BLOCKED) are not the same states, but either of these states will cause the thread to wait for something before continuing execution. The difference is that BLOCKED threads wait some I/O operation to complete (successfully or with an error), whereas TIMED_WAITING threads wait for a signal from some other thread in the JVM, or a given amout of time to elapse, whichever comes first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few basic questions about sockets programming. I am trying to write
I have some basic questions around understanding fundamentals of Performance testing. I know that
I have a few basic questions regarding the syntax and usage of properties in
I'm working through the Stanford iPhone podcasts and have some basic questions. The first:
Dup of Some Basic PHP Questions Hello, I have a heap of tinyint fields
I just had some basic php questions to further my understanding as I learn,
I have some questions about basic CSS that I was unable to understand or
I do know some basic differences but there are still some questions in my
Continuing on previous questions ( here , and here ), I implemented a basic
I'm working on kernel design, and I've got some questions concerning paging. The basic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.