1)I am creating a ios app in which I have to scan a pool of IP address. Each one can take time , so I want to implement multithread in my app.
I was about to use thread class but I have doubts regarding that how many threads we can create simuntaneoulsy. Its mentioned in developer.apple guide that each thread would take 512KB memory. So, wouldnt that make my app hang , suppose I create 100 threads or may be more that that ?
2) one doubt regarding threading:do each thread create their own object(to operate) when I pass same object to all threads.Actually,They all are performing same task
3)if I go for GCD(grand central dispatch) then do I have any advantage ? ie would that help me in this particular situation.
3)Also, one last thing. what would be the best way to perform a task which are similar but need to perform concurrently(in order to improve performance). Note:
All these threads use same object method to perform task.
Thanks and regards , if i sound weird
IMO, the simplest thing to do is perform your scan in a single thread (or a single block that is dispatch_async’d) and then use a kqueue to deal with the results efficiently. The kqueue API takes a little getting used to but is an efficient way to do what you want. The basic idea is: