[Shootout-list] Re: process creation
Isaac Gouy
igouy2@yahoo.com
Mon, 1 Nov 2004 08:49:57 -0800 (PST)
> should be changed for the better
We already have a test that will provide process creation measurements
for a whole range of languages - chain.
public class chain {
static final int LENGTH = 1000;
public static void main(String args[]) {
int n = 1;
if (args.length > 0) n = Integer.parseInt(args[0]);
int count = 0;
while (n-- > 0) {
Link chain = null;
Link link = null;
synchronized(Link.hold){
for (int i=1; i<=LENGTH; i++){
link = new Link(chain,count);
link.start();
chain = link;
count = chain.count;
}
}
}
System.out.println(count);
}
}
class Link extends Thread {
public static Boolean hold = new Boolean(true);
private Link next;
public int count;
Link(Link t, int i){
next = t;
count = i + 1;
}
public void run() {
synchronized(hold){}
}
}
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail