Thu, 19 Sep 2013 09:36:51 -0700
Added tag jdk8-b108 for changeset 85072013aad4
coleenp@3698 | 1 | /* |
coleenp@3698 | 2 | * Copyright 2012 SAP AG. All Rights Reserved. |
coleenp@3698 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
coleenp@3698 | 4 | * |
coleenp@3698 | 5 | * This code is free software; you can redistribute it and/or modify it |
coleenp@3698 | 6 | * under the terms of the GNU General Public License version 2 only, as |
coleenp@3698 | 7 | * published by the Free Software Foundation. |
coleenp@3698 | 8 | * |
coleenp@3698 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
coleenp@3698 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
coleenp@3698 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
coleenp@3698 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
coleenp@3698 | 13 | * accompanied this code). |
coleenp@3698 | 14 | * |
coleenp@3698 | 15 | * You should have received a copy of the GNU General Public License version |
coleenp@3698 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
coleenp@3698 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
coleenp@3698 | 18 | * |
coleenp@3698 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
coleenp@3698 | 20 | * or visit www.oracle.com if you need additional information or have any |
coleenp@3698 | 21 | * questions. |
coleenp@3698 | 22 | */ |
coleenp@3698 | 23 | |
coleenp@3706 | 24 | public class TestPostFieldModification { |
coleenp@3698 | 25 | |
coleenp@3706 | 26 | public String value; // watch modification of value |
coleenp@3698 | 27 | |
coleenp@3706 | 28 | public static void main(String[] args){ |
coleenp@3698 | 29 | |
coleenp@3706 | 30 | System.out.println("Start threads"); |
coleenp@3706 | 31 | // this thread modifies the field 'value' |
coleenp@3706 | 32 | new Thread() { |
coleenp@3706 | 33 | TestPostFieldModification test = new TestPostFieldModification(); |
coleenp@3706 | 34 | public void run() { |
coleenp@3706 | 35 | test.value="test"; |
coleenp@3706 | 36 | for(int i = 0; i < 10; i++) { |
coleenp@3706 | 37 | test.value += new String("_test"); |
coleenp@3698 | 38 | } |
coleenp@3698 | 39 | } |
coleenp@3706 | 40 | }.start(); |
coleenp@3698 | 41 | |
coleenp@3706 | 42 | // this thread is used to trigger a gc |
coleenp@3706 | 43 | Thread d = new Thread() { |
coleenp@3706 | 44 | public void run() { |
coleenp@3706 | 45 | while(true) { |
coleenp@3706 | 46 | try { |
coleenp@3706 | 47 | Thread.sleep(100); |
coleenp@3706 | 48 | } catch (InterruptedException e) { |
coleenp@3706 | 49 | |
coleenp@3706 | 50 | } |
coleenp@3706 | 51 | System.gc(); |
coleenp@3706 | 52 | } |
coleenp@3698 | 53 | } |
coleenp@3706 | 54 | }; |
coleenp@3706 | 55 | d.setDaemon(true); |
coleenp@3706 | 56 | d.start(); |
coleenp@3698 | 57 | } |
coleenp@3698 | 58 | } |