Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Maximum number of threads - error

Reply
Thread Tools

Maximum number of threads - error

 
 
mark
Guest
Posts: n/a
 
      11-22-2006
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

 
Reply With Quote
 
 
 
 
M.J. Dance
Guest
Posts: n/a
 
      11-22-2006
mark wrote:
> 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.


http://www.google.com/search?q=java+threadpool
 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      11-22-2006

mark wrote:
> 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


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

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

 
Reply With Quote
 
mark
Guest
Posts: n/a
 
      11-23-2006
Hello,

> Look into ThreadPoolExecutor

<http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/concurrent/ThreadPoolExecutor.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

 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      11-24-2006

mark wrote:
> Hello,
>
> > Look into ThreadPoolExecutor

> <http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/concurrent/ThreadPoolExecutor.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


You're welcome.

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      11-27-2006
Daniel Pitts wrote:
> Look into ThreadPoolExecutor
>

<http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/concurrent/ThreadPoolExecutor.html>
>
> There is a lot of nifty things in the java.util.concurrent package.
> Although they require java 1.5.


mark wrote:
> 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
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      11-27-2006

Lew wrote:
> Daniel Pitts wrote:
> > Look into ThreadPoolExecutor
> >

> <http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/concurrent/ThreadPoolExecutor.html>
> >
> > There is a lot of nifty things in the java.util.concurrent package.
> > Although they require java 1.5.

>
> mark wrote:
> > 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


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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
maximum number of threads Paul Sijben Python 12 01-12-2007 10:10 AM
Creating the maximum number of menus and maximum number of stills rossco DVD Video 2 11-24-2005 09:33 PM
Maximum number of threads Kirby Angell Python 7 10-04-2004 05:52 AM
The number name 'System.Web.UI.WebControls' contains more than the maximum number of prefixes. The maximum is 3. mayur ASP .Net Web Controls 2 07-16-2004 05:14 PM
The number name 'System.Web.UI.WebControls' contains more than the maximum number of prefixes. The maximum is 3. mayur ASP .Net 2 07-02-2004 10:35 AM



Advertisments