Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Maximum number of threads - error

Thread view: 
mark - 22 Nov 2006 00:55 GMT
Hello,

I have just built an application (J2SE) which creates many threads for
I/O socket operations. Under very specific circumstances (very slow
network connection, many I/O operations) I got an error:

Exception in thread "main" java.lang.OutOfMemoryError: unable to create
new native thread

Therefore I am just wondering is it possible to put all the threads to
some finite queue (which size would be specified by the operating
system) so that it could execute only some of the threads keeping the
rest in the queue (FIFO preferably). All the threads are independent so
there should be no problems with blocking. I just wanted to do so just
to improve my performance and avoid such errors in very specific cases.
Would be very grateful for help.

Best, Markus
M.J. Dance - 22 Nov 2006 08:40 GMT
> Hello,
>
[quoted text clipped - 12 lines]
> to improve my performance and avoid such errors in very specific cases.
> Would be very grateful for help.

http://www.google.com/search?q=java+threadpool
Daniel Pitts - 22 Nov 2006 18:07 GMT
> Hello,
>
[quoted text clipped - 14 lines]
>
> Best, Markus

Look into ThreadPoolExecutor
<http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/concurrent/ThreadPo
olExecutor.html
>

There is a lot of nifty things in the java.util.concurrent package.
Although they require java 1.5.
mark - 23 Nov 2006 23:36 GMT
Hello,

> Look into ThreadPoolExecutor
<http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/concurrent/ThreadPo
olExecutor.html
>
> There is a lot of nifty things in the java.util.concurrent package.

Thank you Daniel - that was the thing I was looking for (even if it
still needs 1.5 :)).

Regards, mark
Daniel Pitts - 24 Nov 2006 18:07 GMT
> Hello,
>
[quoted text clipped - 6 lines]
>
> Regards, mark

You're welcome.
Lew - 27 Nov 2006 06:14 GMT
Daniel Pitts wrote:
> Look into ThreadPoolExecutor

<http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/concurrent/ThreadPo
olExecutor.html
>

> There is a lot of nifty things in the java.util.concurrent package.
> Although they require java 1.5.

> Thank you Daniel - that was the thing I was looking for (even if it
> still needs 1.5 :)).

Java 5 has been out for two years now.  It's up to revision 9.  It's not beta
software any more, folks.

- Lew
Daniel Pitts - 27 Nov 2006 07:22 GMT
> Daniel Pitts wrote:
>  > Look into ThreadPoolExecutor
[quoted text clipped - 11 lines]
>
> - Lew

That is true, and oh what a wonderful world it would be if every Java
shop had completely ported existing Java 1.4 (or lower) applications to
the latest stable Java.  Unfortunately, the real world is often
neglectful of such considerations, as 1.5 is not 100% backward
compatible.

I would start all of my new projects in 1.5, and port any 1.4 project
if I had the choice.  Luckily my Job allows me to start new projects in
1.5, but we have legacy systems to support.

Although, it seems Mark is fine using 1.5, which is very much a good
thing.

- Daniel.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.