Guest User

Untitled

a guest
Jun 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. public class Main
  2. {
  3.     /**
  4.      * @param args
  5.      */
  6.     public static void main(String[] args)
  7.     {
  8.         AtomicReference<TValue<Integer>> counter = new AtomicReference<TValue<Integer>>(new TValue<Integer>(0));
  9.        
  10.         TContext c = new TContext();
  11.         c.priority = 0;
  12.         int i = 0;
  13.        
  14.         do
  15.         {
  16.             try
  17.             {
  18.                 c.txNew();
  19.  
  20.                 c.txWrite(counter, 212);
  21.                 i = c.txRead(counter);
  22.  
  23.                 c.txCommit();
  24.             }
  25.             catch (AbortException e)
  26.             {
  27.                 if (c.txRethrowAbort())
  28.                 {
  29.                     throw e;
  30.                 }
  31.             }
  32.         } while (!c.txIsCommitted());
  33.        
  34.         do
  35.         {
  36.             try
  37.             {
  38.                 c.txNew();
  39.  
  40.                 c.txWrite(counter, c.txRead(counter) - 1);
  41.  
  42.                 c.txCommit();
  43.             }
  44.             catch (AbortException e)
  45.             {
  46.                 if (c.txRethrowAbort())
  47.                 {
  48.                     throw e;
  49.                 }
  50.             }
  51.         } while (!c.txIsCommitted());
  52.        
  53.         if (i == 212)
  54.         {
  55.             devices.Console.println("Yes");
  56.         }
  57.         else
  58.         {
  59.             devices.Console.println("No");
  60.         }
  61.     }
  62. }
Add Comment
Please, Sign In to add comment