++count; //    Read Modify Write

long long value; // 64bit
value = 0; // 32bit
int x,y; //

x = 1;
y = 2;
//            y==2 && x==1
int x,y; //

x = 1;
y = 2;
//            y==2 && x==1
//
x = 1;
y = 2;
//       y==2 && x==1

//
y==2      x==1
//
x = 1;
y = 2;
//       y==2 && x==1

//
y==2      x==1
bool read_flag = false;

//
read_file(buffer); //
read_flag = true;

//
while( ! read_flag ); // read
write_console(buffer); //
bool read_flag = false;

//
read_file(buffer); //
read_flag = true;

//
while( ! read_flag ); // read
write_console(buffer); //
bool read_flag = false;

//
read_file(buffer); //
read_flag = true;

//
while( ! read_flag ); // read
write_console(buffer); //
bool read_flag = false;

//
read_file(buffer); //
read_flag = true;

//
while( ! read_flag ); // read
write_console(buffer); //
public static Singleton getInstance()
{
  if (instance == null)
  {
      synchronized(Singleton.class) { //1
         if (instance == null)      //2
             instance = new Singleton(); //3
      }
  }
  return instance;
}
public static Singleton getInstance()
{
  if (instance == null)
  {
      synchronized(Singleton.class) { //1
         if (instance == null)      //2
             instance = new Singleton(); //3
      }
  }
  return instance;
}
public static Singleton getInstance()
{
  if (instance == null)
  {
      synchronized(Singleton.class) { //1
         if (instance == null)      //2
             instance = new Singleton(); //3
      }
  }
  return instance;
}
Matuura concurrent

Matuura concurrent

  • 8.
    ++count; // Read Modify Write long long value; // 64bit value = 0; // 32bit
  • 9.
    int x,y; // x= 1; y = 2; // y==2 && x==1
  • 10.
    int x,y; // x= 1; y = 2; // y==2 && x==1
  • 11.
    // x = 1; y= 2; // y==2 && x==1 // y==2 x==1
  • 12.
    // x = 1; y= 2; // y==2 && x==1 // y==2 x==1
  • 14.
    bool read_flag =false; // read_file(buffer); // read_flag = true; // while( ! read_flag ); // read write_console(buffer); //
  • 15.
    bool read_flag =false; // read_file(buffer); // read_flag = true; // while( ! read_flag ); // read write_console(buffer); //
  • 16.
    bool read_flag =false; // read_file(buffer); // read_flag = true; // while( ! read_flag ); // read write_console(buffer); //
  • 17.
    bool read_flag =false; // read_file(buffer); // read_flag = true; // while( ! read_flag ); // read write_console(buffer); //
  • 31.
    public static SingletongetInstance() { if (instance == null) { synchronized(Singleton.class) { //1 if (instance == null) //2 instance = new Singleton(); //3 } } return instance; }
  • 32.
    public static SingletongetInstance() { if (instance == null) { synchronized(Singleton.class) { //1 if (instance == null) //2 instance = new Singleton(); //3 } } return instance; }
  • 33.
    public static SingletongetInstance() { if (instance == null) { synchronized(Singleton.class) { //1 if (instance == null) //2 instance = new Singleton(); //3 } } return instance; }