Back
Close

Computing with Data

elgeish
33.1K views

Thread Safety - Part I

In this chapter, we will be mainly using Java to explore parallel computing concepts that, given they're supported, can be easily translated into other programming languages.

Note: Code examples in this chapter may sacrifice best OOP practices, like encapsulation, for demonstration purposes and brevity.

# Example 1 - single-threaded logic
def do_work():
print('Hello, world!')
do_work()
# Example 2 - multi-threaded logic
from threading import Thread
for t in (Thread(target=do_work) for _ in range(10)):
t.start()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants