File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change
1
+ package symjava .examples ;
2
+
3
+ import static symjava .symbolic .Symbol .x ;
4
+ import static symjava .symbolic .Symbol .y ;
5
+ import symjava .bytecode .BytecodeFunc ;
6
+ import symjava .symbolic .Expr ;
7
+ import symjava .symbolic .utils .JIT ;
8
+
9
+ /**
10
+ * test class loader for multi thread case
11
+ * @author yueming.liu
12
+ *
13
+ */
14
+ public class ExampleMultiThread {
15
+
16
+ public static void main (String [] args ) throws InterruptedException {
17
+ Thread t = new Thread (new Runnable () {
18
+ @ Override
19
+ public void run () {
20
+ Expr R = 0.127 -(x *0.194 /(y +0.194 ));
21
+ Expr Rdy = R .diff (y );
22
+ System .out .println (Rdy );
23
+
24
+ //Just-In-Time compile the symbolic expression to native code
25
+ BytecodeFunc func = JIT .compile (new Expr []{x ,y }, Rdy );
26
+ System .out .println (func .apply (0.362 , 0.556 )); //Scala function call operator
27
+ System .out .println (func .call (0.362 , 0.556 )); //Groovy function call operator
28
+
29
+ }
30
+ });
31
+ t .start ();
32
+ t .join ();
33
+ }
34
+
35
+ }
Original file line number Diff line number Diff line change 1
1
package symjava .symbolic .utils ;
2
2
3
+ import symjava .bytecode .BytecodeFunc ;
4
+
3
5
import com .sun .org .apache .bcel .internal .generic .ClassGen ;
4
6
5
7
public class FuncClassLoader <T > extends ClassLoader {
6
8
7
9
public FuncClassLoader () {
8
- super (Thread .currentThread ().getContextClassLoader ());
10
+ //super(Thread.currentThread().getContextClassLoader());
11
+ //https://blogs.oracle.com/sundararajan/understanding-java-class-loading
12
+ //super(java.lang.ClassLoader.getSystemClassLoader());
13
+ super (BytecodeFunc .class .getClassLoader ());
9
14
}
10
15
//
11
16
// public FuncClassLoader(ClassLoader parent) {
You can’t perform that action at this time.
0 commit comments