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

asp.net - Change the driver in the connection string to a data source in VB.Net -

objective c - iPhone and it's wireless area -

unix - Listing all shared memory segments used by a process on AIX5.3+ -