The synchronized method is applied the instance of a class. If I need to synchronize for the class, could anyone here send me a reference? For example, the class A has 2 instances, a1 and a2. The thread 1 is running on a1, and thread 2 is running on a2. I expect the 2 threads can be synchronized. We may need to use static member(s) on the class A, but do we have to?
z*n
4 楼
Manager or Director of Engineering GH2Power (北京氢璞创能科技有限公司) is a startup for developing reforming based fuel cell systems aiming for markets ranging from telecommunication, automobile, to military. The company has set realistic goals for the next 3-5 years and is in process to further improve its technology for better system efficiency and reliability. For detail information, please visit www.gh2power.com. The company is looking to fill the position of manager or director of engineering, depending on the experience. The position will be based in Beijing, China with competitive compensation package. The engineering manager/director is responsible for developing plans for and directing both internal and external funded projects according to the company strategic planning. The incumbent will confer with management, production and marketing staff to determine product specifications in each market segment; prepare project schedule and budget ; analyze technology and resource needs to assess the feasibility of projects; recruit talents and form project teams. The incumbent should have an engineering degree with at least 5 years of successful management role in an industrial environment. Experiences on development of electromechanical systems are strongly desirable. A successful team leader consistently sets an example at the factory floor. Fluency (speaking and writing) in both Mandarin Chinese and English is a must. Experiences on fuel cell stack and fuel reformer development are highly desirable. Candidates should send cover letter and resume to e*********[email protected] for consideration.
You should be able to use synchronized (A.class). However, why don't you want to use static member for the lock?
running we
【在 i**p 的大作中提到】 : The synchronized method is applied the instance of a class. : If I need to synchronize for the class, could anyone here send me a : reference? : For example, the class A has 2 instances, a1 and a2. The thread 1 is running : on a1, and thread 2 is running on a2. I expect the 2 threads can be : synchronized. We may need to use static member(s) on the class A, but do we : have to?
Thanks! synchronized (A.class) does help. However, we still need a static data member to help. For example, "available" has to be a static to be shared by all the A's instance. synchronized (A.class) { while (available == false) A.class.wait(); .... } I am trying to find if it is possible to set locks on a class by not using static members.
【在 r*****l 的大作中提到】 : You should be able to use : synchronized (A.class). : However, why don't you want to use static member for the lock? : : running : we
【在 O*******e 的大作中提到】 : the problem is you haven't really watered here before applying for bm ba?
r*l
13 楼
If "available" has business meaning and you have business logic to set it, then you should create such property.
【在 i**p 的大作中提到】 : Thanks! synchronized (A.class) does help. However, we still need a static : data member to help. : For example, "available" has to be a static to be shared by all the A's : instance. : synchronized (A.class) { : while (available == false) : A.class.wait(); : .... : } : I am trying to find if it is possible to set locks on a class by not using