I want pass some parameters (two strings) to the run() method when starting the thread through thread.start().
how can I do that?

You can't since the signature of the run() method is fixed. The way you are doing it suggests you have some custom task which needs to be executed. In that case I would recommend creating a custom Runnable or Thread class which takes those two "strings" as constructor arguments and use them when the "run()" method is invoked.

class WorkItem implements Runnable {

  // declarations

  public WorkItem(final String one, final String two) {
      this.one = one;
      this.two = two;
  }

  @Override
  public void run() {
      // process strings one and two
  }

}

Just pass this Runnable instance to a Thread object and you should be good to go. If there are multiple such work items, a better suggestion would be to use the new utilities provided by the java.util.concurrent package, namely ExecutorService.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.