1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dxc.junit.opcodes.dreturn.jm; 18 19 public class T_dreturn_7 implements Runnable { 20 public final static int CNT = 1000; 21 double value = 0; 22 boolean failed = false; 23 24 public void run() { 25 for(int i = 0; i < CNT; i++) { 26 test(); 27 } 28 } 29 30 private synchronized double test() { 31 value++; 32 double c = value; 33 Thread.yield(); 34 if(c != value) 35 failed = true; 36 return c; 37 } 38 39 public static boolean execute() { 40 T_dreturn_7 test = new T_dreturn_7(); 41 Thread t1 = new Thread(test); 42 Thread t2 = new Thread(test); 43 44 t1.start(); 45 t2.start(); 46 47 try 48 { 49 Thread.sleep(5000); 50 } 51 catch(InterruptedException ie) { 52 return false; 53 } 54 55 if(test.value != CNT * 2) 56 return false; 57 return !test.failed; 58 } 59 60 } 61