Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Java 613 Threads limit: unable to create new native thread
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Philipp Hagemeister  
View profile  
 More options Nov 21 2011, 8:20 am
Newsgroups: linux.debian.maint.java
From: Philipp Hagemeister <phi...@phihag.de>
Date: Mon, 21 Nov 2011 14:20:02 +0100
Local: Mon, Nov 21 2011 8:20 am
Subject: Re: Java 613 Threads limit: unable to create new native thread
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

First of all: What error message do you get? How much memory do you have
in the system? What is the output of  uname -a  on your system?

On my system, this program easily goes to 10000, although it demands a
lot of memory. You may want to specify a lower stack size, like this:

java -Xss150k DieLikeADog

Also, make sure you have sufficient memory available, basically the
number of threads * memory required for an empty thread. Since each
thread seems to take about 100k, this boils down to at least a GiB for
10k threads. YMMV. Note that on a 32-bit architecture, you will run out
of address space long before running out of actual memory. While you
could do crazy things with fork, I *strongly* recommend you use a 64-bit
architecture.

If you plan on having a quadruple-digits number of threads, I suggest
you either rewrite your code to use threadpools or use really fast
hardware with lots of memory (say, 10GiB)..

- -- Philipp

Keyja Keyja wrote:
> Hello,

> I am running the following code on my debian server:

> public class DieLikeADog {
>   private static Object s = new Object();
>   private static int count = 0;
>   public static void main(String[] argv){
>     for(;;){
>       new Thread(new Runnable(){
>           public void run(){
>             synchronized(s){
>               count += 1;
>               System.err.println("New thread #"+count);
>             }
>             for(;;){
>               try {
>                 Thread.sleep(100);
>               } catch (Exception e){
>                 System.err.println(e);
>               }
>             }
>           }
>         }).start();
>     }
>   }
> }

> I got this code here:
> http://stackoverflow.com/questions/763579/how-many-threads-can-a-java...

> On my server, the program crashes after 613 threads. This is not
> normal, and has to be related to my server configuration. I had the OS
> installed when I started to rent the server at http://www.nuxit.com/
> and I never messed with the configuration.

> Debian version: 5.0.8
> Java version: 1.6.0_26

> Can anyone help me please ? I was forced to put my website offline
> because of this bug. I always have this limit of 613 threads no matter
> which program I run on my debian server.

> Can anyone help please ?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEAREKAAYFAk7KR2EACgkQ9eq1gvr7CFya0QCgmuvhMyqwf0M3bnxSIaMYCiWq
P+sAnR8eoOQYirEeiV4bQmb4R6GdEIha
=3fyc
-----END PGP SIGNATURE-----

--
To UNSUBSCRIBE, email to debian-java-REQU...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4ECA4761.2070...@phihag.de


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.