Added double checked locking for shared variable context. getContext() and createSocket() should now be thread safe.