Import code.

TODO : It is nessesary to review the code around thread.
This code includes the code regarding thread that will be deprecated.