aspose file tools
The moose likes Threads and Synchronization and the fly likes Thread locks leading to lack of file handles Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Thread locks leading to lack of file handles" Watch "Thread locks leading to lack of file handles" New topic
Author

Thread locks leading to lack of file handles

Chris Brat
Ranch Hand

Joined: May 22, 2003
Posts: 108
Hi,

A colleague of mine recently told me that he once wrote a web application that made very heavy use of StringBuffer class (JVM version 1.3) in order to generate code (using Javacc) and experienced the problem of running out of file handles.

It was explained to me that the problem was due to the synchronized methods of the StringBuffer class and all the thread locking associated with using it.

I don't know much about this but it sounds very interesting and could explain a problem I had at a previous company.

Please share your opinions or thoughts.

Thanks
Chris


SCJP 1.2, SCJP 5, SCBCD
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16681
    
  19

When an application is running out of file handles, I would look into file objects that are not being closed.

And if it is a synchronization deadlock that is preventing the file objects from being closed, I am sure it is not the StringBuffers...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Chris Brat
Ranch Hand

Joined: May 22, 2003
Posts: 108
Hi,

Thanks for the response.

I would also generally look towards files or sockets not being closed correctly - thats why I'm curious.

Chris
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24041
    
  13

You might ask your colleague for clarification, because either you misunderstood what s/he was trying to say, or, well, s/he did. I'm certainly not aware of any OS that uses file handles as thread locks.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: Thread locks leading to lack of file handles
 
Similar Threads
Threads: synchronizing a block of code (K&B 1.5)
HTTP connection thread problem to SERVLET on APACHE
Threads
java.lang.IllegalAccessError in doGet()
thread safe issue and file open/write