for(Iterator it2 = tries.iterator();it2.hasNext();)
        {
        tobedeleted2 = (FpiRightTree) it2.next();  

        tobedeleted2.setIndex(f);
            f = f+1;
        }

I want to that in thread function.can someone give me help in creating thread?

Tries is global. so in all threads it will be shared. i want to call thread.
to do a for loop from 1 to 3000 and another for loop from 3001 to 6000

is it worth it do threading for this? I want to speed it up.

You have to create the class and a new thread object.

// This class extends Thread
    class BasicThread1 extends Thread {
        // This method is called when the thread runs
        public void run() {
        }
    }

    // Create and start the thread
    Thread thread = new BasicThread1();
    thread.start();

I want to do it in same class

You need to add extends Thread to where you declare the class.

class name extends Thread
public void run() {
      for(Iterator it2 = tries.iterator();it2.hasNext();)
      {
      tobedeleted2 = (FpiRightTree) it2.next();
      tobedeleted2.setIndex(f);
      f = f+1;

stop();
  }
}

ur last code is helpful, do u know how can i pass a parameter to the run?

class name extends Thread

public class()
{
// three threads
run(f);
fun(f);
run(f); 
}
      public void run() {

      for(Iterator it2 = tries.iterator();it2.hasNext();)

      tobedeleted2 = (FpiRightTree) it2.next();

      tobedeleted2.setIndex(f);

      f = f+1;

      stop();

My whole program is finished, i want to use threads to enhance performance.

how many threads u suggest for 40000 for loop?i am thinking of 8 5000 loop threads

That would be the best way to break it up. Why do you have 40,000 for loops in your program? The absolute maximum threads you can have is determined by the amount of memory in the JVM and OS.

there is 40,000 data i am reading from the database. problem is am losing 12 seconds for that.
reading 40,000 data and map them to an object. am working with hibernate

its actually even slower then 12 seconds. but hibernate does caching. which helps me case

do u know how i can do array of threads???

BasicThread[] theThreads = new BasicThread[f134];

            theThreads[f] = new BasicThread(you,you1,you,tries, root1);
            theThreads[f].start();

is that correct?

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.