1

I have a native shared library implemented in C which I'm invoking through java JNI, now I have to access the native library in parallel in multiple java threads the problem is the threads are started after serialization and are independent of one other. so when i try to load the library in all the threads in parallel i see "java.lang.UnsatisfiedLinkError".

i have doubt in how the shared library works in this case and is it possible to access the shared library in multiple threads at the same time? i know that my shared library is thread safe means it doesn't using any global variables.

I'm running the program in Linux box.

Thanks.

technomage
  • 9,861
  • 2
  • 26
  • 40
  • Anybody please help! – parthi_for_tech Sep 03 '14 at 17:06
  • We just need to load the JNI library once, and it will be available to all threads, just like any library would be in C. Are you using a custom class loader from within a container or something by any chance? – Samuel Audet Sep 04 '14 at 01:52
  • Thanks Samuel for reply! I'm using URLClassLoader, the problem is that all the objects are serialized and runs on the machine hence there is no common class to load it. – parthi_for_tech Sep 04 '14 at 04:16
  • It sounds like what you are trying to do is not possible: http://stackoverflow.com/a/16189410/523744 You're going to need to find a way to share the class loaders across your code. – Samuel Audet Sep 04 '14 at 08:55

0 Answers0