コード例 #1
0
 def test_07_02_cancel_future(self):
     future = javabridge.run_script("""
     new java.util.concurrent.FutureTask(
         new java.util.concurrent.Callable() {
            call: function() { return 2+2; }});""")
     wfuture = jutil.get_future_wrapper(future,
                                        fn_post_process=jutil.unwrap_javascript)
     wfuture.cancel(True)
     self.assertTrue(wfuture.isCancelled())
     self.assertRaises(javabridge.JavaException, wfuture.get)
コード例 #2
0
 def test_07_01_wrap_future(self):
     future = javabridge.run_script("""
     new java.util.concurrent.FutureTask(
         new java.util.concurrent.Callable() {
            call: function() { return 2+2; }});""")
     wfuture = jutil.get_future_wrapper(future,
                                        fn_post_process=jutil.unwrap_javascript)
     self.assertFalse(wfuture.isDone())
     self.assertFalse(wfuture.isCancelled())
     wfuture.run()
     self.assertTrue(wfuture.isDone())
     self.assertEqual(wfuture.get(), 4)