FreeBSD vs Windows 2000 "Advanced" Server

Sheldon Hearn sheldonh at starjuice.net
Thu Aug 28 02:08:55 PDT 2003


On (2003/08/28 11:05), Sheldon Hearn wrote:

> The test class at the bottom of this message can fire about 1,800 [1]
> threads on my FreeBSD 5.1-CURRENT box, with the native jdk-1.4.1.  My
> box is a PIII with 1G of RAM.

Oops, make that about 8,000 threads. :-)

And I forgot to include the class source.

Ciao,
Sheldon.


public class TestThreads extends Thread
{
    private long sleepMillis;

    public TestThreads(long sleepMillis)
    {

        this.sleepMillis = sleepMillis;
    }

    public void run()
    {

        try {
            Thread.sleep(sleepMillis);
        } catch (InterruptedException e) {
        }
    }

    public static void main(String[] args)
    {
        int threadCount = 0;
        long sleepMillis = 0;

        try {
            threadCount = new Integer(args[0]).intValue();
            sleepMillis = new Long(args[1]).longValue();
        } catch (Exception e) {
            usage();
        }

        int i = 0;
        try {
            for (i = 0; i < threadCount; i++) {
                TestThreads test = new TestThreads(sleepMillis);
                test.start();
            }
            System.out.println( "TestThreads: successfully fired " +
                threadCount + " threads" );
        } catch (OutOfMemoryError e) {
            System.out.println("TestThreads: after creating " +
                i + " threads: " + e.getMessage());
        }

        try {
            Thread.sleep(sleepMillis);
            System.out.println("TestThreads: waited " + sleepMillis +
                " milliseconds for all threads to complete");
        } catch (InterruptedException e) {
        }
    }

    private static void usage()
    {

        System.err.println("usage: TestThreads threadCount sleepMillis");
        System.exit(1);
    }
}


More information about the freebsd-java mailing list