0

I am running a multithreaded program.

One thread(not the main thread) captures the screen continuously every 200ms and write the data to a TCP socket.

Another thread will listen for incoming data in the TCP socket.

I assume, the problem is caused when I call [NSThread sleepForTimeInterval:0.2], some other thread will start running and it doesn't finish its work before the 200 ms.

How do I know which Thread is currently running? In other words, when the code stays in [NSThread sleepForTimeInterval:] I want to know the current code(with Class Name/Line number) that is being executed?

Ilario
  • 5,979
  • 2
  • 32
  • 46
boopathy
  • 427
  • 2
  • 9
  • 20
  • 1
    It's not clear how the sleeping thread is related to the other thread? Does the sleeping thread require the other thread to finish before it can work? If so, you need to investigate thread sync mechanisms. – trojanfoe Feb 24 '14 at 13:51
  • have you seen this: http://stackoverflow.com/questions/18249749/nsthread-sleepfortimeinterval-blocks-main-thread – Volker Feb 24 '14 at 13:51
  • Is there a reason you sleep the thread beyond setting a timer? If not I'd suggest using `NSTimer` which is designed to have let code run at repeatable timed intervals. Sleeping a thread has lots of other side effects which might not be desirable. – DBD Feb 24 '14 at 14:06

0 Answers0