It is not possible because connection is local variable in both thread functions, no common variables are used.
I checked that it also crashes without SSL. Two threads connecting to the same server, different databases.
Joanna