Skip to content

Challenge 9: threads are not executed in parallel but one by one #2

@deimi

Description

@deimi

In your implementation the list of threads will only contain one thread at a time, which gets immediately started and joined. So in the end nothing will run in parallel

The actual solution should look like this

threads = []
for scribe in self.scribes:
    if len(scribe.moves) > i:
        args = scribe.moves[i][1]+[self]
        threads.append(Thread(target=scribe.moves[i][0], args=args))
[thread.start() for thread in threads]
[thread.join() for thread in threads]
self.print()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions