Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)
Can anyone help me what is Thread safe in Java?

1 Answer

0 votes
by (26.7k points)

Basically, thread-safe can be defined as any method or class that can be able to use multiple threads at the same time without any problems. You can take the below example:

private int myInt = 0;

public int AddOne()

{

    int tmp = myInt;

    tmp = tmp + 1;

    myInt = tmp;

    return tmp;

}

I hope this will help.

Want to become a Java Expert? Join Java Certification now!!

Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java Programming:

Related questions

0 votes
1 answer
0 votes
1 answer
asked Mar 22, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer

Browse Categories

...