multithreading - Do lock objects in Java need to be static? -


I know in C # when you have an object that you want to use as a lock for multi-threading You must declare it stable inside a class, which class instances will be running in different threads.

Is this also true for Java? Some examples online only begin declaring the last object as a lock object ...

EDIT: I have a resource that I want to limit to only one thread access at a time. A class that extends the thread will be used to create many instances and will start at the same time.

Thanks

Depending on which context they are used they will be used. If you want a per-instance lock, go away still . If you want a per-class lock, use still in addition to actually put it the last .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -