# Running A grph with out Creating IThreadManager object

**URL:** https://forum.cloverdx.com/t/running-a-grph-with-out-creating-ithreadmanager-object/831
**Category:** CloverDX Platform
**Created:** [March 3, 2011, 12:00am UTC](https://forum.cloverdx.com/t/running-a-grph-with-out-creating-ithreadmanager-object/831 "2011-03-03T00:00:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![venkata](https://avatars.discourse-cdn.com/v4/letter/v/f4b2a3/32.png) [@venkata](https://forum.cloverdx.com/u/venkata)
#### Post date: [March 3, 2011, 12:00am UTC](https://forum.cloverdx.com/t/running-a-grph-with-out-creating-ithreadmanager-object/831/1 "2011-03-03T00:00:00Z")

</div>

Hi Team,

I have created a graph file, I can i able to call the graph, through java by using following code

EngineInitializer.initEngine(“C:\\cloverETL.rel-3-0-0\\cloverETL\\plugins”, null, null);  
String graphPath = “c:\\cloverETL.rel-3-0-0\\cloverETL\\bin\\graph\\test.grf”;  
InputStream is = new BufferedInputStream(new FileInputStream(graphPath));

TransformationGraph graph = null;  
// engine customizationnm  
GraphRuntimeContext runtimeContext = new GraphRuntimeContext();  
// graph loading  
graph = TransformationGraphXMLReaderWriter.loadGraph(is,runtimeContext);  
// engine initialization  
EngineInitializer.initGraph(graph, runtimeContext);

// graph running  
IThreadManager threadManager = new SimpleThreadManager();  
WatchDog watchDog = new WatchDog(graph, runtimeContext);  
threadManager.executeWatchDog(watchDog);

while executing the graph, i am creating the **IThreadManager** object.  
ThreadManager is creating new thread and running it Separately.  
I have a problem here, after calling the graph, i am excepting the result from the same thread(where i am executing the above code). Since graph execution is happening in new thread, I am not able to trace when the graph execution is completed.

Here my requirement is like this, once graph after the execution of the graph, i have to proceed the another process.

When i am calling the threadManager.executeWatchDog(watchDog) , the main thread is initiating other thread to execute the graph, once the new thread starts executing then main thread is call the next process in the flow. But the actual requirement is needed to wait till the graph execution complete and then has to proceed for others.

My problem in one line:-

Is it possible to execute the graph, with out creating the ThreadManager object.

Thank you  
VENKAT

---

<div class="post-metadata">

### Author: ![mzatopek](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mzatopek](https://forum.cloverdx.com/u/mzatopek)
#### Post date: [March 3, 2011, 2:10pm UTC](https://forum.cloverdx.com/t/running-a-grph-with-out-creating-ithreadmanager-object/831/2 "2011-03-03T14:10:12Z")

</div>

Hi VENKAT,

if I understand well, your only issue is, you would like to have a control over the graph result. In other words, you would like to run graphs one to each other. Correct me if I am wrong.

First of all, I would recommend you to use a little bit easier construction instead of obsolete:

// graph running  
IThreadManager threadManager = new SimpleThreadManager();  
WatchDog watchDog = new WatchDog(graph, runtimeContext);  
threadManager.executeWatchDog(watchDog);

use this simple code instead:

// execute the graph  
Future futureResult = runGraph.executeGraph(graph, runtimeContext);  
// wait for a result  
Result result = futureResult.get(); //this method blocks current thread until graph is finished

And this snipped of code shows you also how to wait for the graph result. The Future is something like a handler of running graph. For example you can trigger few graphs at once and this handlers can be used to grab graph results later. If you are interested in Futures, let’s look at [http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html](http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html).

I hope it helped. Let me know if you need more help with clover integration.

Martin

---

<div class="post-metadata">

### Author: ![venkata](https://avatars.discourse-cdn.com/v4/letter/v/f4b2a3/32.png) [@venkata](https://forum.cloverdx.com/u/venkata)
#### Post date: [March 4, 2011, 5:08am UTC](https://forum.cloverdx.com/t/running-a-grph-with-out-creating-ithreadmanager-object/831/3 "2011-03-04T05:08:54Z")

</div>

Hi Martin,

Thanks for your solution. It is working fine.

Thanks  
VENKAT
