The problem is more complicated than this. System level library functions are not thread aware, so when a library is unloaded in one thread but still loaded in another you won't detect the error.