3666N/A/*
3666N/A * Copyright 2012 SAP AG. All Rights Reserved.
3666N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3666N/A *
3666N/A * This code is free software; you can redistribute it and/or modify it
3666N/A * under the terms of the GNU General Public License version 2 only, as
3666N/A * published by the Free Software Foundation.
3666N/A *
3666N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3666N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3666N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3666N/A * version 2 for more details (a copy is included in the LICENSE file that
3666N/A * accompanied this code).
3666N/A *
3666N/A * You should have received a copy of the GNU General Public License version
3666N/A * 2 along with this work; if not, write to the Free Software Foundation,
3666N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3666N/A *
3666N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3666N/A * or visit www.oracle.com if you need additional information or have any
3666N/A * questions.
3666N/A */
3666N/A
3674N/Apublic class TestPostFieldModification {
3666N/A
3674N/A public String value; // watch modification of value
3666N/A
3674N/A public static void main(String[] args){
3666N/A
3674N/A System.out.println("Start threads");
3674N/A // this thread modifies the field 'value'
3674N/A new Thread() {
3674N/A TestPostFieldModification test = new TestPostFieldModification();
3674N/A public void run() {
3674N/A test.value="test";
3674N/A for(int i = 0; i < 10; i++) {
3674N/A test.value += new String("_test");
3666N/A }
3666N/A }
3674N/A }.start();
3666N/A
3674N/A // this thread is used to trigger a gc
3674N/A Thread d = new Thread() {
3674N/A public void run() {
3674N/A while(true) {
3674N/A try {
3674N/A Thread.sleep(100);
3674N/A } catch (InterruptedException e) {
3666N/A
3674N/A }
3674N/A System.gc();
3674N/A }
3674N/A }
3674N/A };
3674N/A d.setDaemon(true);
3674N/A d.start();
3666N/A }
3666N/A}