img
.
To insert TNF probes into Java code, you need to make calls outside the JVM. It's a bit awkward
to do, but not particularly difficult, as we show in Code Example 14-1.
Example 14-1 Code Using TNF Probes in Java
// TNFExample
/*
Show how to use TNF from Java.
(Only a bit messy.)
*/
import java.io.*;
import java.util.*;
import Extensions.*;
class ProbedObject {
public native void objectCreateStart();
public native void objectCreateEnd();
static {System.loadLibrary("javaProbe");}
}
class TNFExample implements Runnable {
static SingleBarrier barrier = new SingleBarrier(1);
public static void main (String[] arg) throws Throwable {
long startTime = System.currentTimeMillis();
long endTime;
if (arg.length == 0) {
System.out.println("Running single-threaded");
new TNFExample().run();
// Non-threaded
} else {
System.out.println("Running multi-threaded");
for (int i = 0; i < 1; i++) {
new Thread(new TNFExample()).start();
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home