Saturday, July 23, 2016

Is This A 'thread Deadlock'?

Is This A 'thread Deadlock'?

Hi guys,

 

Yesterday I was playing with threads and using a global variable to determine if a thread had finished or not.

 

Pseudo code

// thread
loop until finished
set 'done' to true when finished

 

// main loop
loop until 'done' is true

 

I found that the program would stall in the main loop and never terminate.

 

I also found by locking 'done' in both the thread and main loop resolved the issue.

 

Is this an example of a deadlock?

 

 


No comments:

Post a Comment