Threadsafe system

Created a simple thread-safe bayesian system for working with a bayesian model