I am writing an application that is going to send / receive data on TCP connection and I have time to read / write I want to define the run loop of a different thread. Earth Thread 1 is making connections and scheduling it on the thread loop of thread 2. I am unable to find any way to reach the run loop of a different thread, so I wrote a piece of code that will run the secondary thread that will store its move loop in a globally accessible location. I wanted to know if this is the right way to do this or if there is any other / better way to do this, and if I did this then problems arise like access to the run loop like thread is not safe and issues if I I try to schedule a lot of things from multiple threads on the loop to run the same thread.
Something like that
[NSRunLoop currentRunLoop] -> This can I do with thread from which I want to use the Runalpop
NSRunLoop * secondthreadrunloop = [secondthread getRunLoop]; - But is there anything like that?
I recently encountered the same problem and it seems that the answer is - no , You can not schedule anything on the NSrun Loop running on a separate thread. Apple says that the NSRon loop is not secure, which means that it is an undefined behavior by linking it to an instance of NSTimer (I checked it, in my case it crashes randomly).
Although what can be done is to schedule the repeated timer from the background thread and it wants to work from some nuclear property.
Comments
Post a Comment