Using the same approach on JDK1.3.1, deadlock can occur (as described in bug #4558745). Problem described here was never reproduced in JDK1.3.1.
JDK version:
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b89)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b89, mixed mode)
Steps to reproduce:
1. Run attached JEP application
2. run "xclipboard" application
3. Paste some text into the testing app.
4. Select some text
5. Try to perform copy operation (Ctrl-C)
6. Look into to the xclipboard for clipboard content, it is often empty. It is not possible to perform paste operation (nothing is in clipboard).
7. If problem does not occur, repeat steps 4, 5, 6.
This problem is not reproducible without "xclipboard".
The original bug report against NetBeans is here:
http://www.netbeans.org/issues/show_bug.cgi?id=18246