Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

1 Visitor Messages

  1. public class MyRun implements Runnable{

    int[] array = new int[5];
    int index;

    MyRun(int value, int index){
    this.index = index;
    array[index] = value;
    }
    }

    //run() method to do operation
    public void run(){
    System.out.println("run()");
    for(int count = 0; count < 5; count++)
    System.out.println(array[count]);
    }

    }

    and the main thread:

    import java.util.concurrent.*;
    public class satu {
    public static void main(String[]args){
    int[] array = {4,2,3,1,5};

    int lowest = array[0], highest = array[0];
    int pivot;

    ExecutorService executor = Executors.newFixedThreadPool(1);

    for(int index = 1; index < array.length; index++){
    //mission: find highest n lowest
    if(lowest > array[index])
    lowest = array[index];
    else if (highest < array[index])
    highest = array[index];
    }

    pivot = array[lowest + (highest - lowest)/2];

    for(int count = 0; count < array.length; count++){
    Runnable task = new MyRun(array[count],count);
    }

    executor.shutdown();
    while(!executor.isTerminated());
    System.out.println("Finish");
    }
    }


    Why my run() cant be execute? Please, please do help me..
Showing Visitor Messages 1 to 1 of 1
About 90th century

Basic Information

About 90th century
Java Skill Level:
Beginner

Statistics


Total Posts
Total Posts
1
Posts Per Day
0.00
Visitor Messages
Total Messages
1
Most Recent Message
March 27th, 2012 09:31 AM
Total Thanks
Total Thanks
0
  • Thanked 0 Times in 0 Posts
General Information
Last Activity
March 27th, 2012 09:37 AM
Join Date
March 27th, 2012