0

I have a weird problem with my threaded software.

I start 2 instances of the software. Each instance has 2 threads, one thread creates a socket to use, and the other one is uses the socket for communication.

When one of the threads in one instance calls sleep(3), the other threads in the the other instance sleeps too. And the weirdest thing is that when I rebooted the computer, it works the first time, but after trying a second time, it sleeps like described.

How is this possible? Is it using some shared resource?

DeeD
  • 89
  • 2
  • 8
  • For a moment there the question title made me think you were asking about an threaded application who were sleeping around with "other" application ;-p – Pharaun May 14 '10 at 14:39

2 Answers2

2

Sleep suspends your process, not your thread. See sleep vs pthead_yield for more details.

Community
  • 1
  • 1
Devon_C_Miller
  • 16,248
  • 3
  • 45
  • 71
-1

Have you tried wrapping your sleep function in a prophylactic?

Rakis
  • 7,779
  • 24
  • 25