Add extra thread synchronization

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
Protect against invalid JNI data retrieval

Handler posts are asynchronous and can try to get module data from a
released module, so add a flag to avoid this situation and prevent
native crashes.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
Synchronize viewer change

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>