ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Multithreading with C#
Subject:   First example
Date:   2001-10-05 06:30:18
From:   alasdair
The first code example on page 1 ("Creating and Running Threads") is not valid Java and will not even compile. I assume there must have been some typographical glitch .... Anyway, here is a working implementation for that example:


public class ThreadingExample
{
public static void main( String args[] )
{
Thread[] threads = new Thread[2];
for( int i=0;i<2;i++ )
{
threads[i] = new Thread( new Runnable()
{
public void run()
{
count();
}
} );
threads[i].start();
}
}


public static void count()
{
for( int count=1;count<=5;count++ )
System.out.print( i + " " );


}
}


1 to 1 of 1
  1. First example
    2001-10-05 06:32:28  alasdair [View]

1 to 1 of 1