<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>deadlock example in c - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/deadlock-example-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/deadlock-example-in-c/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Wed, 08 Sep 2021 12:08:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>deadlock example in c - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/deadlock-example-in-c/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What is deadlock in threads with Example ?</title>
		<link>https://www.wikitechy.com/interview-questions/operating-system/what-is-deadlock-in-threads-with-example/</link>
					<comments>https://www.wikitechy.com/interview-questions/operating-system/what-is-deadlock-in-threads-with-example/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 20 Jul 2021 08:46:02 +0000</pubDate>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Allstate Solutions Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Atos interview questions and answers]]></category>
		<category><![CDATA[AVEVA Software interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[database deadlock]]></category>
		<category><![CDATA[deadlock]]></category>
		<category><![CDATA[deadlock avoidance]]></category>
		<category><![CDATA[deadlock condition]]></category>
		<category><![CDATA[deadlock definition]]></category>
		<category><![CDATA[deadlock detection]]></category>
		<category><![CDATA[deadlock example]]></category>
		<category><![CDATA[deadlock example in c]]></category>
		<category><![CDATA[deadlock exception in java]]></category>
		<category><![CDATA[deadlock in dbms]]></category>
		<category><![CDATA[deadlock in java]]></category>
		<category><![CDATA[deadlock in java with realtime example]]></category>
		<category><![CDATA[deadlock in operating system]]></category>
		<category><![CDATA[deadlock in os]]></category>
		<category><![CDATA[deadlock meaning]]></category>
		<category><![CDATA[deadlock prevention]]></category>
		<category><![CDATA[deadlock prevention in os]]></category>
		<category><![CDATA[define deadlock]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[explain deadlock situation in java]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[HCL Technologies interview questions and answers]]></category>
		<category><![CDATA[how to avoid deadlock in c]]></category>
		<category><![CDATA[how to avoid deadlock in java]]></category>
		<category><![CDATA[how to avoid deadlock in multithreading]]></category>
		<category><![CDATA[how to debug deadlock in java]]></category>
		<category><![CDATA[how to detect deadlock and fix it in java]]></category>
		<category><![CDATA[how to detect deadlock in java]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[java deadlock example]]></category>
		<category><![CDATA[java deadlock example and solution]]></category>
		<category><![CDATA[java detect deadlock thread dump]]></category>
		<category><![CDATA[jvm deadlock detection]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Opentext Technologies interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[oracle deadlock]]></category>
		<category><![CDATA[Prokarma Sof interview questions and answers]]></category>
		<category><![CDATA[RBS India Development Centre Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[sql deadlock]]></category>
		<category><![CDATA[Tata Consultancy Service interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[thread deadlock in java]]></category>
		<category><![CDATA[to prevent deadlock never use synchronized block or method]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[Virtusa Consulting Services Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Wells Fargo interview questions and answers]]></category>
		<category><![CDATA[what is deadlock]]></category>
		<category><![CDATA[what is deadlock in os]]></category>
		<category><![CDATA[what is deadlock in oswrite a deadlock and resolve it in java]]></category>
		<category><![CDATA[write a deadlock and resolve it in java]]></category>
		<category><![CDATA[xoxo interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=1115</guid>

					<description><![CDATA[Answer : Deadlock is one of the part of multithreading.synchronized keyword is used to...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="deadlock-in-threads" class="color-pink" style="text-align: justify;"><span style="font-family: inherit; font-size: 2rem;">Deadlock in Threads</span></h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Deadlock is one of the part of multithreading.</li>
<li><b>synchronized</b> keyword is used to make the class or method thread-safe which means only one thread can have lock of synchronized method and use it, other threads have to wait till the lock releases and anyone of them acquire that lock.</li>
<li>Deadlock can occur in a situation when a thread is waiting for an object lock, that is acquired by another thread and second thread is waiting for an object lock that is acquired by first thread.</li>
<li>Since, both threads are waiting for each other to release the lock, the condition is called deadlock.</li>
</ul>
</div>
</div>
<div class="text-center row" style="text-align: justify;">
<div class="col-sm-12"></div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/operating-system/what-is-deadlock-in-threads-with-example.png" alt=" Deadlock in Threads " /></div>
</div>
<p style="text-align: justify;" align="center">Deadlock in Threads</p>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="example-of-deadlock-in-thread" class="color-purple">Example of Deadlock in Thread</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">public class DeadlockExample {  <br/>  public static void main(String[] args) {  <br/>    final String resource1 = &quot;MS Dhoni&quot;;  <br/>    final String resource2 = &quot;Virat Kholi&quot;;  <br/>    // t1 tries to lock resource1 then resource2  <br/>    Thread t1 = new Thread() {  <br/>      public void run() {  <br/>          synchronized (resource1) {  <br/>           System.out.println(&quot;Thread 1: locked resource 1&quot;);  <br/>  <br/>           try { Thread.sleep(100);} catch (Exception e) {}  <br/>  <br/>           synchronized (resource2) {  <br/>            System.out.println(&quot;Thread 1: locked resource 2&quot;);  <br/>           }  <br/>         }  <br/>      }  <br/>    };  <br/>  <br/>    // t2 tries to lock resource2 then resource1  <br/>    Thread t2 = new Thread() {  <br/>      public void run() {  <br/>        synchronized (resource2) {  <br/>          System.out.println(&quot;Thread 2: locked resource 2&quot;);  <br/>  <br/>          try { Thread.sleep(100);} catch (Exception e) {}  <br/>  <br/>          synchronized (resource1) {  <br/>            System.out.println(&quot;Thread 2: locked resource 1&quot;);  <br/>          }  <br/>        }  <br/>      }  <br/>    };  <br/>  <br/>      <br/>    t1.start();  <br/>    t2.start();  <br/>  }  <br/>} </code></pre> </div>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-blue">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs" data-lang=""><span class="nt"><strong>Thread 1: locked resource 1
Thread 2: locked resource 2</strong></span></code></pre>
</figure>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/operating-system/what-is-deadlock-in-threads-with-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
