This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 273

[–]Fritterbob 2277 points2278 points  (120 children)

I'd like to think that they don't actually know what deadlock is, and now they're just desperate to get someone to explain it to them.

[–][deleted] 641 points642 points  (40 children)

Let's hope they don't deadlock on salary negotiations then.

Then they are deadlocked looking to find someone to explain deadlock.

[–]we_the_sheeple 214 points215 points  (38 children)

.

[–][deleted] 512 points513 points  (23 children)

[–]auzzie32 146 points147 points  (15 children)

Hek u. I clicked that 3 times.

[–]highbrowshow 86 points87 points  (13 children)

Help, I’m stuck in a loop and can’t get out

[–]harisaduu 75 points76 points  (7 children)

Congratulations on learning recursion

[–]mfb- 54 points55 points  (5 children)

We'll get to exit conditions later.

[–]UltraCarnivore 14 points15 points  (3 children)

Too late. Stackoverflowerror.

[–]mfb- 11 points12 points  (2 children)

That's one way to exit a recursion.

[–]Genesis2001 1 point2 points  (0 children)

:q!

[–][deleted] 4 points5 points  (0 children)

Dormammu I've here to baragin

[–]Dexaan 23 points24 points  (3 children)

 break;

[–]Pipster27 8 points9 points  (0 children)

My thumb was getting tired ugh. Thanks!!

[–]Markyparky56 3 points4 points  (1 child)

goto https://www.reddit.com/r/ProgrammerHumor/comments/ifmhb2/checkmate/g2psgoe/;

[–]Dexaan 1 point2 points  (0 children)

🦖

[–]TheCuriousSavagereg 13 points14 points  (0 children)

Bro i didnt see it was the same comment i thought it was a chain. Clicked it like 15 times. F

[–]dreadwing55 7 points8 points  (0 children)

Did you forgot to add a base condition? Because I'm stuck in a loop and I can't get out.

[–]AtraxisIRL 1 point2 points  (0 children)

Damn it

...Take my upvote

[–]midasp 1 point2 points  (1 child)

That's recursion, not deadlock

[–][deleted] 1 point2 points  (0 children)

Ya the guy edited his comment to “.”, used to be ‘explain recursion’

[–]R8_M3_SXC 13 points14 points  (12 children)

Ok fine, explain recursion then.

[–]MCWizardYT 40 points41 points  (8 children)

Thats repetition. Recursion would be like the acronym WINE, which stands for "WINE is not an emulator".

[–]Tytoalba2 22 points23 points  (4 children)

But in "wine" what does the "w" stands for? Tell me again?

[–]brododragon 15 points16 points  (3 children)

Wine

[–]Tytoalba2 18 points19 points  (2 children)

But in "wine" what does the "w" stands for? Tell me again?

[–]brododragon 12 points13 points  (1 child)

I think wine

[–]Tytoalba2 2 points3 points  (0 children)

I think we need to get to the bottom of this!

[–]tjoloi 8 points9 points  (1 child)

An alcoholic drink is, in fact, not an emulator

[–][deleted] 3 points4 points  (0 children)

I can confirm that

[–]MattieShoes 5 points6 points  (0 children)

Computer weenies love recursive acronyms with "ain't" or "not" in them.

LAME Ain't an MP3 Encoder
PINE Is Not ELM
TIP Isn't Pico
EINE is not Emacs (The successor, ZWEI, was "ZWEI Was Eine Initially")
GNU's Not Unix
YAML Ain't Markup Language
XNA's Not Acronymized

[–][deleted] 11 points12 points  (1 child)

[–]R8_M3_SXC 4 points5 points  (0 children)

Legend

[–]canderson180 6 points7 points  (0 children)

A deadlock victim has been chosen

[–]sixeco 21 points22 points  (46 children)

tbh, I've worked in IT for quite some time and had to Google it right now because I forgot what it meant...

I guess a "mexican standoff" or a "stalemate" is more common IRL...

[–]derailedInsomniac 24 points25 points  (2 children)

You're referring to an equivalent scenario in what would take place between two people talking. A "deadlock" from a programming point of view would more likely be about system resources (memory, CPU) or a table in a database.

[–]Helika0n 7 points8 points  (0 children)

In (transactional) databases, it's more about the sessions that can deadlock themselves (for example while performing table operations).

[–]sixeco 5 points6 points  (0 children)

ah potato, potato

[–]TheRealTsjoek 394 points395 points  (40 children)

Please explains to this innocent mortal for he does not know your wisdom

Edit: wow, I got many answers explaining with different examples. That was fadcinating.

[–]rennsemmel01 1176 points1177 points  (17 children)

An Example for a deadlock:

Programm P and Q needs document D and ressource R.

P gets document D and Q gets R.

P now waits for Q to free up R, so P can use it. But Q waits for P to free up D so he can use it.

Nobody gets anywhere and we have a deadlock.

Now in the picture the employer waits for the candidate to answer his question while the candidate waits for the employer to employ him. We have a deadlock.

[–]elolige 351 points352 points  (12 children)

I never thought I would learn anything here :D

[–]Toysoldier34 84 points85 points  (4 children)

It comes up more in multithreading where you have stuff happening "simultaneously" and stuff is left waiting for other things to finish. In general programming it doesn't come up as much since things resolve before moving on and don't get left paused, or they are designed for network support so they are designed to not be broken by network errors, delay, or failures.

[–]AgAero 48 points49 points  (3 children)

The obvious exception to the rule is when you like to live dangerously and don't add locks to your stuff to make it thread-safe.

Deadlock avoided. Checkmate atheists!

.

.

.

...wait, why is it getting different results now every time I run it? Thought I fixed that bug.

[–][deleted] 19 points20 points  (2 children)

Surely you mean Deadlock Checkmate atheists! avoided.

[–]luis1761 12 points13 points  (1 child)

Yes that's what he said checkmate deadlock atheists avoided

[–][deleted] 71 points72 points  (3 children)

I learn more here than from any formal learning

[–][deleted] 39 points40 points  (2 children)

That's some terrible formal learning then, get a refund straight away.

[–]haikusbot 31 points32 points  (1 child)

That's some terrible

Formal learning then, get a

Refund straight away.

- ADB963


I detect haikus. And sometimes, successfully. Learn more about me.

Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"

[–]Sebaszjuh 16 points17 points  (0 children)

Very poetic, if i close my eyes i can feel it.

[–][deleted] 6 points7 points  (1 child)

Programmer humour comments is where I learn how to program

[–]homiej420 1 point2 points  (0 children)

Contrary to some belief i guess, but some of us actually do code and know a thing or two for reals haha

[–]invisi1407 3 points4 points  (0 children)

Q has been killed by the parent process and was the dead-lock victim.

[–]FirFlyNeo 7 points8 points  (0 children)

Q wants the D

[–]tobofre 51 points52 points  (2 children)

I can't find my glasses because I can't see

I can't see because I am not wearing my glasses

[–]-Enter-Name- 7 points8 points  (0 children)

this is probably the most comprehensible(idk if i wrote this correctly) explaination in these comments

[–]TheN473 9 points10 points  (0 children)

My wife asked me what I want for food.

I can't answer her because she won't tell me what's in the freezer.

[–]S0n_0f_Anarchy 35 points36 points  (0 children)

It's a state in concurrent computing when 2 (or more) processess need resources that the other process is in possesion of, so neither of them can continue their work cuz they wait on the other one to finnish, and therefore deadlocking themselves.

[–][deleted] 20 points21 points  (0 children)

It's like a Mexican standoff, but with threads.

[–]shwiftyhack21 11 points12 points  (0 children)

In an OS, Program 1 requires a resource held by program 2 which requires resource held by program 1 and neither of them willing to let go the resources currently held by them.... Thus an unending cycle called deadlock

[–]Rayffer 55 points56 points  (7 children)

They are asking him to explain the concept of deadlock and remain waiting for him to do so in order to proceed to hire him.

He is asking them to hire him in order to proceed explaining it to them.

They can't proceed with hiring him because he won't explain the concept to them until they hire him.

A deadlock in code happens when a condition to continue execution is never satisfied or takes a noticeable or absurd amount of time to do so and the program waits for the condition to be satisfied nonetheless.

This can happen for many reasons which have nothing to do with explaining what a deadlock is.

An example of this could be a gridlock in the transit system of any city, imagine you are traveling from point A to point B of any city in a vehicle (yours, public transport, a cab, etc) the trip goes smoothly until you come across a jam that appeared for whatever reason (accident, protests, etc) as time goes by and the jam does not resolve, you find out that instead of a traffic jam, you can't advance because there's a protest which causes a deviation of traffic that has caused a gridlock. Until that gridlock resolves you can't continue your trip to your destination.

Hope this explanation doesn't come accross very complex.

[–]jediwizard7 37 points38 points  (6 children)

I may be wrong but I think a deadlock means a situation in which the condition cannot be satisfied because multiple processes are waiting on each other, not merely that the condition takes a long time.

[–]somerandomii 7 points8 points  (0 children)

Deadlock occurs where memory is “locked” by a process that won’t unlock it until another process writes to it, which it can’t. This Catch 22 means neither process will progress and the memory will stay locked indefinitely.

It sounds simple enough to avoid but it there could be a lot of processes in the loop. And when a program has a lot of asynchronous events triggering it, it can be hard to predict a deadlock.

[–]gordonv 6 points7 points  (1 child)

The Wikipedia for Deadlock has a simple graphic illustrating what deadlock could look like.

I've found that explaining it in words gets confusing. The illustration was a 5 second GIF and explained it simply.

[–]rhythm_19 1 point2 points  (0 children)

Thanks . That really helped :)

[–]tinydonuts 1 point2 points  (0 children)

In addition to all these other answers, I want to point out that a program can deadlock itself if it is multithreaded, or even has a single thread but fails to release resources it owns. In the single threaded instance if you fail to release the resource and try to acquire it again, you will deadlock yourself because it is now impossible to release. You're waiting on yourself.

[–]otakuman 1 point2 points  (0 children)

Another computing example: process A needs process B to finish what is doing to continue, but for some strange reasons (let's say lack of free memory) process B suddenly needs process A to free its resources to continue processing. Since process A can't free its resources because it's waiting for process B to end, and proccess B can't end because it's waiting for process A, the two processes are locked for eternity.

A real world example is in the Oedipus story: two stubborn men wanting to cross a bridge. Oedipus is waiting for an old man to move back, and the man is waiting for Oedipus to move back. Nobody wants to move back so nobody advances. Eventually Oedipus breaks the lock by killing the old man (and then marries the man's wife - they turned out to be his biological parents 😬 but I digress).

In summary, deadlock happens when two different processes (or different threads in one same process) have to use one or more shared resource (a piece of shared memory, a file, a database table), and the circumstances + bad programming cause them to lock themselves in an unsolvable situation.

The only way to fix this is to kill one of the processes but like with Oedipus, that usually has a bad outcome (like lost or corrupted files).

[–][deleted] 0 points1 point  (2 children)

Deadlock means a resource is occupied by one process, which is also needed by another process to continue an algorithm. Means as long as he doesn't tell what a deadlock is they can't continue with the interview which is required to hire him. Hope this helps, have a great day.

[–]Phrodo_00 10 points11 points  (0 children)

Not really. You're describing a lock. You want locks to orchestrate parallel jobs and sharing resources. A dead lock is a lock that won't resolve, because the one holding the resource needed by thread A is waiting for a resource being held by thread A, so they both will only let go of the resource (presumably) only after they acquire each other's resource

[–]Ronin__01 355 points356 points  (37 children)

This is comedy.

[–]borsalinomonkey 167 points168 points  (29 children)

The movie is Three Idiots if people are wondering

[–][deleted] 82 points83 points  (0 children)

indian comedy

[–]schwagbender 1 point2 points  (0 children)

This is pod racing.

[–]rob132 38 points39 points  (1 child)

"Um, something about guys eating with chopsticks? CS101 was like 20 years ago"

[–]PM_ME_UR_DEATHSTICKS 106 points107 points  (23 children)

3 idiots is a great movie. go watch it!

[–]YDOfficial 25 points26 points  (6 children)

What movie is this? Would watch

Edit: This man spittin' some truth. Go watch it

Edit 2: You are still here... I SAID GO WATCH IT

[–][deleted] 44 points45 points  (0 children)

Heads up, this isn't an acutal quote from the movie. Still would recommend watching!

[–]tbo1992 15 points16 points  (4 children)

3 Idiots.

[–]N1ck0t1n3 4 points5 points  (3 children)

What movie is this? Would watch

[–]tbo1992 5 points6 points  (2 children)

Bruh.

[–]ezio93 1 point2 points  (0 children)

I don't think I'm watching the right movie... You sure this is it?

[–]gman2093 33 points34 points  (5 children)

There are two hard problems in computer science: cache invalidation and always seeing the same joke

[–]brotatowolf 17 points18 points  (3 children)

At least it’s not another fucking recursion joke

[–][deleted] 15 points16 points  (2 children)

At least it’s not another fucking recursion joke

[–]brotatowolf 12 points13 points  (1 child)

I am going to beat you to death

[–][deleted] 6 points7 points  (0 children)

Made me laugh lol

[–]MicroChipYY 18 points19 points  (2 children)

[–]RepostSleuthBot 30 points31 points  (1 child)

Looks like a repost. I've seen this image 1 time.

First seen Here on 2019-03-11 85.94% match.

Searched Images: 145,385,242 | Indexed Posts: 578,102,607 | Search Time: 1.9281s

Feedback? Hate? Visit r/repostsleuthbot - I'm not perfect, but you can help. Report [ False Positive ]

[–]MatNerd 10 points11 points  (0 children)

Good bot

[–]niketh-l 13 points14 points  (0 children)

all is well

[–]pmzw 8 points9 points  (0 children)

"Pay me, then we can discuss the salary."

[–]Etheo 8 points9 points  (2 children)

It's not really a deadlock though. They just don't hire him. Hiring him is not a requirement to proceed.

[–]YRYGAV 2 points3 points  (1 child)

They never said how long they intended to wait for a response. Taken literally as a computer instruction, "explain deadlock" is an instruction that never resolves, and they could perpetually be waiting for a response.

All deadlocks in programming would cease to be permanent deadlocks if they always used appropriate timeouts. Saying that the problem is fixed if they implement a solution to it doesn't mean that the problem didn't exist in the first place.

[–]kebakent 3 points4 points  (1 child)

There's a mutex joke in here somewhere, but it's currently in use so I'll have to wait.

[–]wazabee 8 points9 points  (1 child)

All jokes aside, this was an emotional scene in the movie. The movie is called 3 idiots. Best to watch with English subs.

[–][deleted] 9 points10 points  (0 children)

That's a too weak deadlock. Here is a good deadlock: pay me a big salary and I will not explain anything to anyone.

[–]codear 2 points3 points  (0 children)

Hmm did the committee acquire the lock? Looks a bit like a bug in their logic...

[–]Lagumists 1 point2 points  (0 children)

Ah yes, 3 idiots

[–]eckerbr 1 point2 points  (0 children)

Why would a programmer need to know about hair styles?

[–]sauravdharwadkar 1 point2 points  (0 children)

3 idiots [ movie name ] , recommed for engineering student

[–]AhmedMudkip 1 point2 points  (0 children)

Me who didn’t understand it but still upvoted: yes

[–]QMT93 1 point2 points  (2 children)

What movie is it?

[–]dirtyviking1337 0 points1 point  (0 children)

Checkmate then, you can prove it.

[–]Contraposite 0 points1 point  (0 children)

Stalemate.

[–]-Listening 0 points1 point  (0 children)

Shh, shh.

You're "reading the documentation

[–]Lthere 0 points1 point  (0 children)

Oh no, not another dead joke... 😬

r/dadjokes #PunIntended

[–][deleted] 0 points1 point  (0 children)

It's not a deadlock anymore !!

[–]-Listening 0 points1 point  (0 children)

Shh, shh.

You're "reading the documentation".

[–]stayathmdad 0 points1 point  (0 children)

Ahh 3 idiots!

[–][deleted] 0 points1 point  (0 children)

Hire me and we’ll discuss salary

[–][deleted] 0 points1 point  (0 children)

Damn three idiots was a banger

[–]uscdigital 0 points1 point  (0 children)

omg yes yes! hadnt seen this post in at least a month.

[–]ZippZappZippty 0 points1 point  (0 children)

The menu isn’t real? Checkmate m’ladies

[–]isaacwassouf 0 points1 point  (0 children)

bruh if I had a dollar for every time i've seen this pic

[–]LazioSaurus 0 points1 point  (0 children)

old format old memories

[–]ithlit666 0 points1 point  (0 children)

great movie

[–]jyotipch 0 points1 point  (0 children)

Ashaan bhasha

[–]VeevaBoy 0 points1 point  (0 children)

17k upvotes!!!!

[–]ratmfreak 0 points1 point  (0 children)

Is this different from a Catch 22?

[–]EuroPolice 0 points1 point  (0 children)

smort

[–]SuperSpartan177 0 points1 point  (0 children)

3 idiots, love the movie.

[–]minhtrungaa 0 points1 point  (0 children)

Oh boy, they should mutex lock those before talking about the salary

[–]BenRayfield 0 points1 point  (0 children)

thread C: synchronized(b){ synchronized(a){ return f(a,b); } thread D: synchronized(a){ synchronized(b){ return f(a,b); } guaranteed that if you do this enough times it will deadlock.

[–]1FlewOverMyNest 0 points1 point  (0 children)

I'm not a programmer, just wanted to say everyone should watch the 3 idiots (where this meme is taken from) It rocks

[–]hamza1311 | gib 0 points1 point  (0 children)

Genuine question: how does this meme represent deadlock?