-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: use BytecodeFunc.class.getClassLoader() for FuncClassLoader
- Loading branch information
Yueming Liu
committed
May 31, 2018
1 parent
ee53447
commit 6d5ac8d
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package symjava.examples; | ||
|
||
import static symjava.symbolic.Symbol.x; | ||
import static symjava.symbolic.Symbol.y; | ||
import symjava.bytecode.BytecodeFunc; | ||
import symjava.symbolic.Expr; | ||
import symjava.symbolic.utils.JIT; | ||
|
||
/** | ||
* test class loader for multi thread case | ||
* @author yueming.liu | ||
* | ||
*/ | ||
public class ExampleMultiThread { | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
Thread t = new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
Expr R = 0.127-(x*0.194/(y+0.194)); | ||
Expr Rdy = R.diff(y); | ||
System.out.println(Rdy); | ||
|
||
//Just-In-Time compile the symbolic expression to native code | ||
BytecodeFunc func = JIT.compile(new Expr[]{x,y}, Rdy); | ||
System.out.println(func.apply(0.362, 0.556)); //Scala function call operator | ||
System.out.println(func.call(0.362, 0.556)); //Groovy function call operator | ||
|
||
} | ||
}); | ||
t.start(); | ||
t.join(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters