Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / bindings / java / org / simgrid / msg / Mutex.java
1 /* Copyright (c) 2012-2022. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 package org.simgrid.msg;
8 /** A mutex  implemented on top of SimGrid synchronization mechanisms.
9  * You can use it exactly the same way that you use the mutexes,
10  * but to handle the interactions between the processes within the simulation.
11  *
12  * Don't mix simgrid synchronization with Java native one, or it will deadlock!
13  */
14 public class Mutex {
15         private long bind; // The C object -- don't touch it
16
17         public Mutex() {
18                 init();
19         }
20
21         /** @deprecated (from Java9 onwards) */
22         @Deprecated @Override
23         protected void finalize() throws Throwable {
24                 nativeFinalize();
25         }
26         private native void nativeFinalize();
27         private native void init();
28         public native void acquire();
29         public native void release();
30
31         /** Class initializer, to initialize various JNI stuff */
32         public static native void nativeInit();
33         static {
34                 org.simgrid.NativeLib.nativeInit();
35                 nativeInit();
36         }
37 }
38
39