I'm trying to intialize Screen class inside a Callable in Java but its stuck until Callable timeout

Asked by Samuel on 2017-03-27

I'm trying to initialize Screen class inside Callable in Java but its somehow stuck until Callable throw a timeout exception.
If I tried the same setup using Thread/Runnable its running properly without any problem.
Is there anything I missed?

ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Boolean> future = executor.submit(new Callable<Boolean>() {
  @Override
  public Boolean call() throws Exception {
                Screen s = new Screen();
  }
});

edit : added example code

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2017-03-28
Last query:
2017-03-28
Last reply:
2017-03-27
Best RaiMan (raimund-hocke) said : #1

SikuliX 1.1.x is not threadsafe in any case and will never be.

Try this:
at startup of your app, before doing anything else put:
Screen globalScreen = new Screen();

this should initialize the SikuliX internals.

... and then you could use the object globalScreen all over the place as some "singleton".

Take care, that SikuliX features are not run in parallel without some basic locking.

Samuel (samuel-alf) said : #2

Thanks RaiMan, that solved my question.