0% completed
.....
.....
.....
mailman14736
· 25 days ago
Terrible Python example: threading does not get past the Python Global interpreter lock, meaning that this (being a CPU bound problem, supposedly) does not actually give any speedup. Update to use multi-processing.
Mahendra Reddy
· 2 years ago
When multiple threads are updating ***isSame*** variable
isSame &= isSameTreeMultiThreaded(p.left, q.left, numThreads/2); SIMILAR TO isSame = isSame & isSameTreeMultiThreaded(p.left, q.left, numThreads/2);
- It reads isSame which is thread safe gives latest value due to primitive
- & operator with isSame variable ( one more, by the time it evaluates through recursive function, isSame variable could be outdated )
- Updating isSame variable which is thread safe due to primitive
But, All the above 3 steps together is not atomic.
Consider the scenario:
isSame is true by default,
- Thread-1 reads as true
- Thread-2 reads as true
- Thread-1 receives false from recursive function and updates it with *false
Mike Xu
· 4 years ago
For the Space Complexity of the non-multi-threaded solution, why does the stack take O(N) space but to store nodes we need O(H)? O(N) and O(H) should be the same, right?
Ray
· 4 years ago
As a non-Java user, I expect other language solutions (python, JS, etc) presented here since they are present in the other chapters & courses. Thank you
Mi Nguyen
· 4 years ago
Where is python :((
Jason
· 4 years ago
I would love a C++ solution for the thread safe questions!
Reading Progress
0%