Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

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!')
# Example 2 - multi-threaded logic
from threading import Thread
for t in (Thread(target=do_work) for _ in range(10)):
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content