PageRenderTime 123ms CodeModel.GetById 44ms RepoModel.GetById 3ms app.codeStats 0ms

/trunk/Examples/test-suite/java/director_thread_runme.java

#
Java | 36 lines | 27 code | 8 blank | 1 comment | 1 complexity | 6245c7c2c86ad28e87bceaca017b14ac MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import director_thread.*;
  2. import java.lang.reflect.*;
  3. public class director_thread_runme {
  4. static {
  5. try {
  6. System.loadLibrary("director_thread");
  7. } catch (UnsatisfiedLinkError e) {
  8. System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
  9. System.exit(1);
  10. }
  11. }
  12. public static void main(String argv[]) {
  13. // This test used to hang the process. The solution is to call DetachCurrentThread in ~JNIEnvWrapper, however it causes seg faults in other JNI calls on older JDKs on Solaris. See SWIG_JAVA_NO_DETACH_CURRENT_THREAD in director.swg.
  14. director_thread_Derived d = new director_thread_Derived();
  15. d.run();
  16. if (d.getVal() >= 0) {
  17. throw new RuntimeException("Failed. Val: " + d.getVal());
  18. }
  19. }
  20. }
  21. class director_thread_Derived extends Foo {
  22. director_thread_Derived() {
  23. super();
  24. }
  25. public void do_foo() {
  26. setVal(getVal() - 1);
  27. }
  28. }