(Newbie to this forum)  thread problems!

Sorry all but I didn’t know where to post this,

I have a threadpool and I want to run a threadpooltest, but when I compile the threadpooltest it says it cannot recognise the fullstop between “out” and “printIn”

Here’s the code:

public class ThreadPoolTest {

   public static void main(String[] args) {
      if (args.length != 2) {
          System.out.printIn("Tests the ThreadPool task.");
          System.out.printIn(
            "Usage: java ThreadPoolTest numTasks numThreads");
          System.out.printIn(
            "  numTasks - integer: number of tasks to run.");
          System.out.printIn(
            "  numThreads - integer: number of threads " + 
            "in the thread pool.");
          return;

      }
      int numTasks = Integer.parseInt(args[0]);
      int numThreads = Integer.parseInt(args[1]);

      //create the thread pool
      ThreadPool ThreadPool = new ThreadPool (numThreads);

      // run example tasks

      for (int i=0; i<numTasks; i++) {
            ThreadPool.runTask(createTask(i));
      }

      // closes the pool and wait for all tasks to finish
      ThreadPool.join();
      }

      /** 
            Creates a simple Runnable that prints an ID, waits 500
            milliseconds, then prints the ID again.
      */

      private static Runnable createTask(final int taskID) {
            return new Runnable() {
                public void run() {
                  System.out.printIn("Task " + taskID + ": start");

                  // simulate a long running task
                  try {
                      Thread.sleep(500);
                  }
                  catch (InterruptedException ex) {}

                  System.out.printIn("Task " + taskID + ": end");
            }
          };
      }
    } 

If anyone can help it would be much appreciated.

Cheers,

Hauk

  1. newbies post in the newbie forum
  2. if you have a compiler error, you need to post the actual error using copy/paste
  3. based on what you pasted, and your use of + in a way that has absolutely no reason nor effect, my guess would be that you have put artificial newlines in your source - you cannot split a line of code across multiple lines of source. This is standard in most languages: one line of code occupies one line of the source file.

Yeah, sorry about that :-/ I only found the newbie forum after I posted this thread.

I’ll post it over there and see what happens.

Thanks