001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Anatoly F. Bondarenko
021: * @version $Revision: 1.2 $
022: */
023:
024: /**
025: * Created on 31.03.2005
026: */package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
027:
028: import org.apache.harmony.jpda.tests.share.SyncDebuggee;
029:
030: /**
031: * The class specifies debuggee for <code>org.apache.harmony.jpda.tests.jdwp.ThreadReference.Status006Test</code>.
032: */
033: public class Status006Debuggee extends SyncDebuggee {
034:
035: static Status006Debuggee status006DebuggeeThis;
036: static volatile boolean status006DebuggeeThreadStarted = false;
037:
038: static Object waitTimeObject = new Object();
039:
040: static void waitMlsecsTime(long mlsecsTime) {
041: synchronized (waitTimeObject) {
042: try {
043: waitTimeObject.wait(mlsecsTime);
044: } catch (Throwable throwable) {
045: // ignore
046: }
047: }
048: }
049:
050: public void run() {
051: logWriter.println("--> Debuggee: Status006Debuggee: START");
052: status006DebuggeeThis = this ;
053:
054: String status006DebuggeeThreadName = "Status006DebuggeeThread";
055: Status006Debuggee_Thread status006DebuggeeThread = new Status006Debuggee_Thread(
056: status006DebuggeeThreadName);
057:
058: status006DebuggeeThread.start();
059:
060: while (!status006DebuggeeThreadStarted) {
061: waitMlsecsTime(1000);
062: }
063: logWriter
064: .println("--> Debuggee: Status006Debuggee: is waiting for Status006DebuggeeThread to finish...");
065: while (status006DebuggeeThread.isAlive()) {
066: waitMlsecsTime(1000);
067: }
068: logWriter
069: .println("--> Debuggee: Status006Debuggee: Status006DebuggeeThread has finished");
070:
071: synchronizer.sendMessage("READY");
072: synchronizer
073: .receiveMessageWithoutException("Status006Debuggee(#1)");
074:
075: logWriter.println("--> Debuggee: Status006Debuggee: FINISH");
076: }
077:
078: public static void main(String[] args) {
079: runDebuggee(Status006Debuggee.class);
080: }
081: }
082:
083: class Status006Debuggee_Thread extends Thread {
084:
085: public Status006Debuggee_Thread(String name) {
086: super (name);
087: }
088:
089: public void run() {
090: Status006Debuggee parent = Status006Debuggee.status006DebuggeeThis;
091: parent.logWriter.println("--> Thread: " + getName()
092: + ": started...");
093: Status006Debuggee.status006DebuggeeThreadStarted = true;
094: parent.synchronizer.sendMessage(getName());
095: parent.synchronizer
096: .receiveMessageWithoutException("Status006Debuggee_Thread(#1)");
097: parent.logWriter.println("--> Thread: " + getName()
098: + ": is finishibg...");
099: }
100: }
|