31/36
Part 8 of 8 · Follow-upsLearn and do

What about several threads? Keep one previous stack per thread

Each sample then carries a thread id, and each thread has its own stack. Keep the previous stack per thread in a dict keyed by thread id. Compare each sample only with that thread's last one.

Tag each event with its thread too, and keep one stack per thread in function_times, the practice problem's function that turns events into time. Merged into one list, two threads' events don't nest like brackets.

Predict

a runs on thread 1 from 0 to 2, and b on thread 2 from 1 to 3. Merged, the events are start a, start b, end a, end b. Do they nest like brackets?

Pick an answer above to see the rest