new FileWriter hangs
- From: "mattias" <killen.med.ruter@xxxxxxxxxxx>
- Date: 30 Jul 2005 22:01:02 -0700
Hello. I have a java program where I repeatedly write to a log file,
and at random times (typically after 100.000 writes or so) the program
just hangs. I've found that this happens while executing a 'new
FileWriter' command. I only have one thread writing to the file,
there's no exceptions thrown or anything, the CPU usage just goes to
zero and then nothing happens at all. Meanwhile, the log file remains
globally locked for writing, i.e. I can't delete it in Explorer without
first killing my java program. I experience this bug on a dual xeon
processor machine, running Windows Server 2003 and java version
1.5.0_04.
Here's the code, it hangs while executing the very first line of code:
FileWriter fileWriter = new FileWriter("log.txt", true);
BufferedWriter buffWriter = new BufferedWriter(fileWriter);
buffWriter.write(message);
buffWriter.newLine();
buffWriter.close();
If anyone has any ideas why this happens, please let me know. I guess
in this case I could leave the file open at all times to avoid this,
but I would be more interested to know the cause of it.
Mattias
.
- Follow-Ups:
- Re: new FileWriter hangs
- From: Thomas Hawtin
- Re: new FileWriter hangs
- From: jan V
- Re: new FileWriter hangs
- From: HGA03630
- Re: new FileWriter hangs
- Prev by Date: Re: The variable bit cpu
- Next by Date: Re: Question about sample Java application
- Previous by thread: help: about hibernate
- Next by thread: Re: new FileWriter hangs
- Index(es):
Relevant Pages
|