File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 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 11package symjava .symbolic .utils ;
22
3+ import symjava .bytecode .BytecodeFunc ;
4+
35import com .sun .org .apache .bcel .internal .generic .ClassGen ;
46
57public class FuncClassLoader <T > extends ClassLoader {
68
79 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 ());
914 }
1015//
1116// public FuncClassLoader(ClassLoader parent) {
You can’t perform that action at this time.
0 commit comments