BufferedReader.readLine() hangs

dave.held_at_arrayservicesgrp.com
Date: 01/31/05


Date: 31 Jan 2005 14:46:52 -0800

The following program hangs on Linux 2.4.20, jre 1.5.0-01-b08,
server VM with a suitably large input file (say, 4+ MB):

import java.io.BufferedReader;
import java.io.FileReader;

public class ReadTest
{
public static void main(String[] args)
{
try
{
BufferedReader in = new BufferedReader(new
FileReader(args[0]));
in.readLine();
do
{
ReadTest.getRow(in);
}
while (in.ready());
}
catch (Exception e)
{
e.printStackTrace();
}
}

public static void getRow(BufferedReader in) throws Exception
{
int n = 0;
while (in.ready())
{
System.out.println(in.readLine());
if (++n > 10) return;
}
}
}

It does not hang in the client VM. It does not hang if the readLine()
call occurs in the outermost loop. It does not hang consistently. It
does not always hang. But when it does hang, it appears to do so
indefinitely. When it hangs, I can suspend the process, and when I
resume it, the process continues normally to completion. Any idea
what is going on?

Dave



Relevant Pages

  • Re: How can I force databinding on all tabs in a Form?
    ... If it still hang, how about the CPU utilization when the program hang? ... "first-chance exception", if yes, maybe the actual execution pointer is not ... Please paste the call stack information as well as the code to generate ... before sending mail. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Thread.join
    ... public static void Main ... The code that you passed do not cause the Thread to hang you will catch the exception in the exception clause. ... The call to Joinon the CurrentThread cannot ever return, because the CurrentThread cannot exit until the call to Joinreturns. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Forced Retirement
    ... He is the exception, tho. ... But most drivers, even included some of the most successful, seem ... MM should hang it up, should be told to hang it up. ...
    (rec.autos.sport.nascar)
  • Re: 0x7c93426d
    ... that the worst what i can be afraid of is another exception ... or a hang as a result of calling ExitProcess. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: using subprocess for non-terminating command
    ... On 7/4/07, O.R.Senthil Kumaran wrote: ... process.stdout.read# This will hang again. ... ping command pruinted to the screen, then the following exception: ... Traceback: ...
    (comp.lang.python)