When we want to split our heavy work within different parts then we hire some people to perform these tasks. So same like this for divide our large C code we can use functions. Basically functions divide our code in different parts and they also create different process contexts. but if we want to do not create different process contexts here will come concept of threads. Threads (LWP Light weight process) used for also divide our work and it will work simultaneously. if we have created main function and then it will create a thread then main thread and called thread will work concurrently. Threads have only their own Stack segment (for its local variable). Main thread or thread functions have used same process context. Threads are not created their own process context.
How to create thread you can see this example and when we go to compilation or linking source code files then we have to use -lpthread library. And if you are working with android-ndk then there is no need to link this library at linking time because in android-ndk there is bionic which supports threads.
And called thread function is here:
Comments
Post a Comment