From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22321 invoked by alias); 3 Jul 2004 04:06:03 -0000 Mailing-List: contact java-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-prs-owner@gcc.gnu.org Received: (qmail 22296 invoked by uid 48); 3 Jul 2004 04:06:02 -0000 Date: Sat, 03 Jul 2004 04:06:00 -0000 From: "efly at javaresearch dot org" To: java-prs@gcc.gnu.org Message-ID: <20040703040557.16342.efly@javaresearch.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug java/16342] New: too many threads error X-Bugzilla-Reason: CC X-SW-Source: 2004-q3/txt/msg00005.txt.bz2 List-Id: Has anybody encountered this problem? When I test java thread using thisiscool gcj3.4, "too many threads" error thrown. Sample source code: class Account { String name; float amount; public Account(String name, float amount) { this.name = name; this.amount = amount; } public void deposit(float amt) { float tmp = amount; tmp += amt; try { Thread.sleep(100); } catch (InterruptedException e) { // ignore } amount = tmp; } public void withdraw(float amt) { float tmp = amount; tmp -= amt; try { Thread.sleep(100); } catch (InterruptedException e) { // ignore } amount = tmp; } public float getBalance() { return amount; } } public class AccountTest { private static int NUM_OF_THREAD = 1000; static Thread[] threads = new Thread[NUM_OF_THREAD]; public static void main(String[] args) { System.out.println("start..."); long start = System.currentTimeMillis(); final Account acc = new Account("John", 1000.0f); for (int i = 0; i < NUM_OF_THREAD; i++) { threads[i] = new Thread(new Runnable() { public void run() { acc.deposit(100.0f); acc.withdraw(100.0f); } }); threads[i].start(); } for (int i = 0; i < NUM_OF_THREAD; i++) { try { threads[i].join(); } catch (InterruptedException e) { // ignore } } long end = System.currentTimeMillis(); System.out.println("Finally, John's balance is:" + acc.getBalance() + " time used:" + (end - start) + "ms"); } } J Zhou efly@javaresearch.org -- Summary: too many threads error Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: critical Priority: P2 Component: java AssignedTo: membar at gcc dot gnu dot org ReportedBy: efly at javaresearch dot org CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16342