public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/16342] New: too many threads error
@ 2004-07-03  4:06 efly at javaresearch dot org
  2004-07-03 18:45 ` [Bug java/16342] [win32] " pinskia at gcc dot gnu dot org
  2004-07-03 22:59 ` [Bug libgcj/16342] " pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: efly at javaresearch dot org @ 2004-07-03  4:06 UTC (permalink / raw)
  To: java-prs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug java/16342] [win32] too many threads error
  2004-07-03  4:06 [Bug java/16342] New: too many threads error efly at javaresearch dot org
@ 2004-07-03 18:45 ` pinskia at gcc dot gnu dot org
  2004-07-03 22:59 ` [Bug libgcj/16342] " pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-03 18:45 UTC (permalink / raw)
  To: java-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
            Summary|too many threads error      |[win32] too many threads
                   |                            |error


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16342


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libgcj/16342] [win32] too many threads error
  2004-07-03  4:06 [Bug java/16342] New: too many threads error efly at javaresearch dot org
  2004-07-03 18:45 ` [Bug java/16342] [win32] " pinskia at gcc dot gnu dot org
@ 2004-07-03 22:59 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-03 22:59 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-03 22:59 -------
This is a dup of bug 14751.

*** This bug has been marked as a duplicate of 14751 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
          Component|java                        |libgcj
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16342


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-07-03 22:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-03  4:06 [Bug java/16342] New: too many threads error efly at javaresearch dot org
2004-07-03 18:45 ` [Bug java/16342] [win32] " pinskia at gcc dot gnu dot org
2004-07-03 22:59 ` [Bug libgcj/16342] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).