Monitors in Java . How variable updated iteratively?

I am going through a slide about Java monitors. I can not understand how this the code below works.

    public synchronized void add( int value){
         int position =  writeIndex ;
                } catch(InterruptedException ex){
               array[position] =  value;
               System.out.print("%s wrote %2d to element %d.%n");
              [![enter image description here][1]][1] Thread.currentThread.getName(),value,position);


Read more here:

Content Attribution

This content was originally published by Perviz Pirizade at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: