SimpleSi
SimpleSi

Reputation: 833

Is a simple function thread safe

if I have this type of program level function

def returnInt(s):
    return int(float(s))

and it ended up being called by 2 separate threads at the same time would it be "thread safe" or do I need to add as a function in both thread classes e.g

class StepperControl(threading.Thread):
....

    def returnInt(self,s):
        return int(float(self.s))

....

class BounceControl(threading.Thread):
....

    def returnInt(self,s):
        return int(float(self.s))

....

Simon

Upvotes: 1

Views: 116

Answers (1)

user1555863
user1555863

Reputation: 2607

Indeed, It is thread-safe, as it does not access or attempt to change anything outside itself.

Upvotes: 3

Related Questions