[libvirt-users] is libvirt java binding thread safe?

Daniel P. Berrange berrange at redhat.com
Fri Sep 3 11:12:26 UTC 2010


On Fri, Sep 03, 2010 at 01:02:09PM +0200, Matthias Bolte wrote:
> Ah, okay, now I understand what you want to say.
> 
> You have two threads A and B. When A runs on its own then it's just
> fine, but when you add B (that triggers an exception on purpose and
> ignores it) then A picks it up and reports it. This is the point where
> thread safety comes to mind.
> 
> libvirt stores errors in thread-local-storage. It uses
> pthread_key_create/pthread_{get,set}specific for this (or
> TlsAlloc/Tls{Get,Set}Value on Windows).
> 
> I think what's happening here is that all your threads in Java share
> the same thread-local-storage. Therefore, thread A can pickup the
> error triggered by thread B, that should not happen.

That could only happen if the JVM was using green threads instead of
native threads, but no serious JVM still uses green threads these days.

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvirt-users mailing list