Projection in a thread.This example shows how to run a projection operation in a thread and how to interrupt it. Its source code is under the samples/java
directory.
import java.io.FileInputStream;
import java.util.Collection;
class ThreadProjection extends Thread
{
public Environment m_env;
private Graph m_g1;
private Graph m_g2;
{
m_env = env;
m_g1 = g1;
m_g2 = g2;
}
public void run()
{
System.out.println("Projection thread: Begin");
try
{
System.out.println(m_env.projectionFind(m_g1, m_g2));
}
catch (Exception e)
{
System.out.println("Projection thread: Exception " + e);
}
System.out.println("Projection thread: End");
}
}
public class JavaProjectionThread
{
public static void main(String args[]) throws Exception
{
String prefix = "..";
if (args.length != 3)
{
System.err.println("3 arguments required (support filename, graph filename, graph filename)");
System.exit(1);
}
System.out.println("Main: Loading");
Collection<EnvironmentObject> c1 = env.loadObjects(args[1]);
Graph g1=(Graph)(c1.iterator().next());
Collection<EnvironmentObject> c2 = env.loadObjects(args[2]);
Graph g2=(Graph)(c2.iterator().next());
ThreadProjection tp = new ThreadProjection(env, g1, g2);
tp.start();
Thread.sleep(100);
System.out.println("Main: Sending stop to projection thread");
tp.m_env.projectionStop();
tp.join();
System.runFinalization();
}
}