I have a Java function that is multi-threaded by OSB (oracle service BUs). This Java function calling three different native function through JNI. How to call these three function in such a way that :
- first function (setting up the system) will call only for 1st thread.
- 2nd function will call by all thread.
3rd function(cleaning up the system) will call only by the last thread. Native functions
setup();
calculation();
Cleanup();
JNI functions
JNIEXPORT jvoid JNICALL Java_taxcalc_setup
JNIEXPORT jstring JNICALL Java_taxcalc_calculation
JNIEXPORT jvoid JNICALL Java_taxcalc_cleanup
Java Code
public class taxcalc{
private static native void setup(); private static native String calculation(String input[],double y,int); private static native void cleanup(); static{ System.loadLibrary("CJavaInterface_64"); taxcalc.setup(); taxcalc.cleanup(); }
public static String taxoutput(String[] args){
String array="";
for(int j=0;j<=5;j++)
{
input[j]=args[j];
}
double y;
int BilledLines;
y=Double.parseDouble(args[6]);
BilledLines=Integer.parseInt(args[7]);
array=taxcalc.calculation(input,y,BilledLines,);
return array;
}
public static void main(String[] args){
System.out.println(taxoutput(args)); }
}
taxouput function is multithreaded from osb.now,i want to call setup() and
cleanup() in way that it,setup() should called only for first thread and
cleanup() should call only for last thread.
f(...)
, and you only want a certain thread to call it, then you should only put calls tof(...)
in the code for that thread. – Solomon Slow