Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
deimi opened this issue Sep 2, 2022 · 0 comments
Open

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

deimi opened this issue Sep 2, 2022 · 0 comments

Comments

@deimi
Copy link

deimi commented Sep 2, 2022

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant