ایک deadlock وہ حالت ہے جہاں دو یا زیادہ threads ہر ایک ہمیشہ کے لیے بلاک ہو جاتے ہیں، ہر ایک ایسے وسیلے کا انتظار کرتے ہوئے جو دوسرا تھامے ہوئے ہے۔ کوئی چیز آگے نہیں بڑھتی۔
چار لازمی (Coffman) شرائط
چاروں کا بیک وقت درست ہونا ضروری ہے — کسی ایک کو بھی ہٹا دیں تو deadlock ناممکن ہے:
1. Mutual exclusion → a resource is held exclusively (only one holder at a time)
2. Hold and wait → a thread holds one resource while waiting to acquire another
3. No preemption → resources can't be forcibly taken; only released voluntarily
4. Circular wait → a cycle: T1 waits for R2 (held by T2), T2 waits for R1 (held by T1)
