ronald-freebsd8 at klop.yi.org
Thu Nov 11 06:37:02 PST 2004
On Wed, 10 Nov 2004 20:39:21 +0000, Martin Grigorov <mcgregory at e-card.bg>
> Hi all,
> I want to ask what type are Java threads in FreeBSD - green or native ?
> I'm using FreeBSD 5.3 and jdk 1.4.2 from ports, actually
> I am a little bit confused: a sysctl entry
> "kern.threads.max_threads_per_proc" says that one process can run max
> 1500 threads. But I wrote test and it crashes with:
> 'Exception in thread "main" java.lang.OutOfMemoryError: unable to create
> new native thread', after starting ~ 8300 threads in the Virtual
> So it sais "native" in the exception, but they are much more than 1500.
Java uses native threads.
About the 'kern.threads.max_threads_per_proc' limit:
The default thread support of FreeBSD 5 (libpthread) doesn't map userspace
threads and kernel thread 1:1.
As long as a thread isn't executing in a part of the kernel it doesn't use
Use top -H to see all threads that are known to the kernel.
If you put this in /etc/libmap.conf you will use a 1:1 thread library and
your program will give (the expected) errors around 1500 threads.
libpthread.so.1 libthr.so.1 # Everything that uses 'libpthread'
libpthread.so libthr.so # now uses libthr.
libc_r.so.5 libthr.so.1 # Everything that uses 'libc_r'
libc_r.so libthr.so # now uses 'libthr'
Because the N:M thread mapping a program can switch between threads
without kernel overhead.
Ronald Klop, Amsterdam, The Netherlands
More information about the freebsd-java