public class Test2 {
public static void main (String [] args) throws Exception
{
final int THREADS = 8;
final long LENGTH = 100000000000L / THREADS;
long start = System.currentTimeMillis ();
Runnable task = new Runnable ()
{
public void run ()
{
long j = 0;
for (long i = 0; i <LENGTH; i ++)
j ++;
}
};
Thread [] threadList = new Thread [THREADS];
for (int i = 0; i <threadList.length; i ++)
{
threadList [i] = new Thread (task);
threadList [i]. start ();
}
for (int i = 0; i <threadList.length; i ++)
threadList [i]. join ();
long end = System.currentTimeMillis ();
System.out.println ("END" + (end - start));
}
}
No comments:
Post a Comment