Index: jdi/org/eclipse/jdi/internal/MirrorImpl.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/MirrorImpl.java,v retrieving revision 1.13 diff -u -r1.13 MirrorImpl.java --- jdi/org/eclipse/jdi/internal/MirrorImpl.java 6 Apr 2005 21:10:47 -0000 1.13 +++ jdi/org/eclipse/jdi/internal/MirrorImpl.java 23 Jun 2005 13:19:32 -0000 @@ -167,21 +167,22 @@ public JdwpReplyPacket requestVM(int command, byte[] outData) { JdwpCommandPacket commandPacket = new JdwpCommandPacket(command); commandPacket.setData(outData); - fVirtualMachineImpl.packetSendManager().sendPacket(commandPacket); - fPendingJdwpRequest = true; - writeVerboseCommandPacketHeader(commandPacket); - - JdwpReplyPacket reply = fVirtualMachineImpl.packetReceiveManager().getReply(commandPacket); - if (fVerboseWriter != null) { - fVerboseWriter.println(); - fVerboseWriter.println("Received reply"); //$NON-NLS-1$ - fVerboseWriter.println("length", reply.getLength()); //$NON-NLS-1$ - fVerboseWriter.println("id", reply.getId()); //$NON-NLS-1$ - fVerboseWriter.println("flags", reply.getFlags(), JdwpPacket.getFlagMap()); //$NON-NLS-1$ - fVerboseWriter.println("error code", reply.errorCode(), JdwpReplyPacket.errorMap()); //$NON-NLS-1$ + synchronized (fVirtualMachineImpl.getCommunicationLock()) { + fVirtualMachineImpl.packetSendManager().sendPacket(commandPacket); + fPendingJdwpRequest = true; + writeVerboseCommandPacketHeader(commandPacket); + + JdwpReplyPacket reply = fVirtualMachineImpl.packetReceiveManager().getReply(commandPacket); + if (fVerboseWriter != null) { + fVerboseWriter.println(); + fVerboseWriter.println("Received reply"); //$NON-NLS-1$ + fVerboseWriter.println("length", reply.getLength()); //$NON-NLS-1$ + fVerboseWriter.println("id", reply.getId()); //$NON-NLS-1$ + fVerboseWriter.println("flags", reply.getFlags(), JdwpPacket.getFlagMap()); //$NON-NLS-1$ + fVerboseWriter.println("error code", reply.errorCode(), JdwpReplyPacket.errorMap()); //$NON-NLS-1$ + } + return reply; } - - return reply; } /** Index: jdi/org/eclipse/jdi/internal/VirtualMachineImpl.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/VirtualMachineImpl.java,v retrieving revision 1.33 diff -u -r1.33 VirtualMachineImpl.java --- jdi/org/eclipse/jdi/internal/VirtualMachineImpl.java 19 Apr 2005 21:01:24 -0000 1.33 +++ jdi/org/eclipse/jdi/internal/VirtualMachineImpl.java 23 Jun 2005 13:19:33 -0000 @@ -73,6 +73,9 @@ /** Timeout value for requests to VM if not overriden for a particular VM. */ private int fRequestTimeout; + /** Lock used to synchronize communication with target VM */ + private Object fCommunicationLock = new Object(); + /** Mapping of command codes to strings. */ private static Map fgHCRResultMap = null; @@ -1322,5 +1325,16 @@ public boolean canBeModified() { return true; } + + /** + * Returns the lock object used to synchronize communication + * with the target VM. + * + * @return the lock object used to synchronize communication + * with the target VM + */ + public Object getCommunicationLock() { + return fCommunicationLock; + } }