This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 269466 - Problem with Scanner class, println and output window
Summary: Problem with Scanner class, println and output window
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 8.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-31 09:31 UTC by curro
Modified: 2016-12-31 09:31 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description curro 2016-12-31 09:31:23 UTC
When I use a Scanner to read input from user several times, there is a problem with the next print line. With this simple code:

                Scanner sc = new Scanner (System.in);
                System.out.println("Introduce first number");
                int number1 = sc.nextInt();
                System.out.println("Introduce second number");
                int number2 = sc.nextInt();

When I run it, appears the first string and wait:

Introduce the first number
_

If I enter 12 for example and press enter, then appears the second string and then my input number and las wait for the second number:

Introduce first number
Introduce second number
12
_

It only happen in Linux (not in MacOS nor Windows). I use Linux Mint distribution. 
I think that is a synchronization thread problem because if I put a Thread.sleep before the first nextInt() all works fine.