-4

I am planning to implementing a multiuser system.

Can I use sleep inside threads. Just want to know will it cause any issues while running multiple threads.

1 Answers1

1

I am planning to implementing a multiuser system.

Good

Can I use sleep inside threads.

Yes

Just want to know it will cause any blocking issues while running multiple threads.

No

However - it is advisable to avoid sleeping in threads unless you really have no choice. You should use inter-thread communications techniques such as BlockingQueues instead if you can.

Some kind of PauseableThread may be a better option.

Community
  • 1
  • 1
OldCurmudgeon
  • 62,806
  • 15
  • 115
  • 208