added lock on session creation.
fixed JNI/Java API.