Added rudimentary threading support

I've just added a small peace of code around the actual sending part of the connection class to introduce sort of rudimentary threading support... For me this appears to work. Though I haven't tested it in every possible context yet. So, feel free to pull the changes into the source rep.