Multiple changes

- Added basic support for multi-threading and synchronization.
- Updated examples.