deadlock fix adapted from patch here https://groups.google.com/forum/#!searchin/simavr/parts$2Fuart_pty$20not$20threadsafe/simavr/eSVV90dFh8U/XwQmSIlrNMIJ
Merge branch 'master' of https://github.com/buserror-uk/simavr