[Core] Fixed a race condition in Thread.

Reference count will be incremented before spawning the Thread that
will execute the task, otherwise the thread might finish, decRef the
task and delete it.

Signed-off-by: Daniel S. Reichenbach <daniel@kogitoapp.com>