I am trying to do the following:

I want to create an array and use methods executed by a thread. all in one class "embedded class"
A method to randomly find largest number which is 0 and then call it max. A method to find 0 and increment it max + 1.
After that calculate the sum of all array. Check the picture it is more clear.
That's what I've done so far but not working as intended
package javaapplication7;
import java.util.*;
import java.util.concurrent.*;
public class JavaApplication7 {
private static Array array = new Array();
public static void main(String[] args) {
ExecutorService executor = Executors.newCachedThreadPool();
Scanner input = new Scanner(System.in);
System.out.println("Enter number");
int num = input.nextInt();
int array[] = new int[num];
for (int i = 0; i < array.length; i++) {
array[i] = 0;
}
for (int i = 0; i < array.length; i++) {
System.out.println("array["+i+"]: "+array[i]);
}
for (int i = 0; i < num; i++) {
executor.execute(new MyThread());
}
executor.shutdown();
while(!executor.isTerminated()){
}
System.out.println("What is balance? ");
}
private static class MyThread implements Runnable{
@Override
public void run(){
array.insert();
}
}
private static class Array{
private int [] array;
private int maximum;
public void setArrayNumbers(){
for (int i = 0; i < array.length; i++) {
array[i] = 0;
}
}
public int getMax(){
return maximum;
}
public synchronized void insert(){
try{
for (int i = 0; i < array.length; i++) {
if(array[i] == 0){
array[i] = array[i] + 1;
}else if(array[i] == 1){
array[i] = array[i] + 1;
}else if(array[i] == 2){
array [i] = array[i] + 1;
}
}
Thread.sleep(100);
}
catch(Exception ex) {
System.out.println(ex);
}
}
}
}
Help me correcting my mistakes so i can understand multithreading better Thank you!