I've run into a problem where multi-threaded Java apps will only use one of the CPUs in a system. I tried both the Sun SDK and the Blackdown SDK: top - 16:37:51 up 1 day, 4:51, 3 users, load average: 1.04, 1.12, 1.17 Tasks: 74 total, 1 running, 73 sleeping, 0 stopped, 0 zombie Cpu0 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si Cpu1 : 0.0% us, 0.3% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si Cpu2 : 100.0% us, 0.0% sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi, 0.0% si Cpu3 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si Mem: 2075848k total, 1926760k used, 149088k free, 295160k buffers Swap: 2096440k total, 0k used, 2096440k free, 925712k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 30041 jetty 16 0 2216m 489m 11m S 99.9 24.1 533:18.63 java archimonde tomcat # cat /proc/version Linux version 2.6.10-gentoo-r2 (root@archimonde) (gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)) #1 SMP Tue Jan 4 11:18:35 CST 2005 archimonde tomcat # java-config -L [sun-jre-bin-1.4.2.06] "Sun JRE 1.4.2.06" (/etc/env.d/java/20sun-jre-bin-1.4.2.06) [blackdown-jdk-1.4.2.01] "Blackdown JDK 1.4.2.01" (/etc/env.d/java/20blackdown-jdk-1.4.2.01) * [sun-jdk-1.4.2.06] "Sun JDK 1.4.2.06" (/etc/env.d/java/20sun-jdk-1.4.2.06) archimonde tomcat # gcc -v Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/specs Configured with: /var/tmp/portage/gcc-3.3.4-r1/work/gcc-3.3.4/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,f77 --enable-threads=posix --enable-long-long --disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --disable-multilib --enable-__cxa_atexit --enable-clocale=generic Thread model: posix gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6) Reproducible: Always Steps to Reproduce: 1. use gentoo-dev-sources-2.6.9+ 2. enable nptl in glibc 3. run a multitheaded java program Actual Results: All threads run on one CPU. Expected Results: Should have loaded each of the 4 virtual CPUs with threads. archimonde tomcat # emerge info Portage 2.0.51-r3 (default-linux/x86/2004.3, gcc-3.3.4, glibc-2.3.4.20040808-r1, 2.6.10-gentoo-r2 i686) ================================================================= System uname: 2.6.10-gentoo-r2 i686 Intel(R) Xeon(TM) CPU 2.40GHz Gentoo Base System version 1.4.16 ccache version 2.3 [enabled] Autoconf: sys-devel/autoconf-2.59-r5 Automake: sys-devel/automake-1.8.5-r1 Binutils: sys-devel/binutils-2.15.90.0.1.1-r3 Headers: sys-kernel/linux26-headers-2.6.8.1-r1 Libtools: sys-devel/libtool-1.5.2-r7 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-O2 -march=pentium4 -msse -msse2 -mmmx -fomit-frame-pointer -pipe" CHOST="i686-pc-linux-gnu" COMPILER="" CONFIG_PROTECT="/etc /opt/jetty/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-O2 -march=pentium4 -msse -msse2 -mmmx -fomit-frame-pointer -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs autoconfig buildpkg ccache distlocks sandbox sfperms" GENTOO_MIRRORS="http://gentoo.osuosl.org http://distro.ibiblio.org/pub/Linux/distributions/gentoo" MAKEOPTS="-j4" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/overlay" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="x86 X X509 acl apache2 apm arts avi berkdb bitmap-fonts crypt encode foomaticdb fortran gdbm gif gpm gtk gtk2 ipv6 java jikes jpeg junit ldap libwww mad mikmod mmap motif mozilla mpeg mysql ncurses nls nptl oggvorbis opengl oss pam pcre pdflib perl php pic pie png python qt quicktime readline rrdtool samba sdl session sftplogging shared snmp spell sse sse2 ssl svga tcpd tiff truetype userlocales xml2 xmms xv zlib"
I ran the following Java outside of Jetty and the application in question: public class MultiThreads extends Thread { String threadName = ""; /** * */ public MultiThreads() { super(); } public static void main(String[] args) { for (int i = 0; i < 4; ++i) { MultiThreads instance = new MultiThreads(); instance.threadName = ""+i; instance.start(); } } public void run() { int i = 0; while (true) { ++i; if (i % 1000000 == 0) System.out.println("Thread "+threadName); } } } This taxxed all 4 virtual processors to 100%, so the problem I'm seeing must somewhere within the application. Oops. Thanks.