Index: /experimental/Threading/Threading.sln
===================================================================
--- /experimental/Threading/Threading.sln	(revision 420)
+++ /experimental/Threading/Threading.sln	(revision 420)
@@ -0,0 +1,20 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Threading", "Threading\Threading.vcproj", "{0DA5F800-C727-4724-8FEE-4787703ED9B6}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{0DA5F800-C727-4724-8FEE-4787703ED9B6}.Debug|Win32.ActiveCfg = Debug|Win32
+		{0DA5F800-C727-4724-8FEE-4787703ED9B6}.Debug|Win32.Build.0 = Debug|Win32
+		{0DA5F800-C727-4724-8FEE-4787703ED9B6}.Release|Win32.ActiveCfg = Release|Win32
+		{0DA5F800-C727-4724-8FEE-4787703ED9B6}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: /experimental/Threading/Threading/ChannelWorker.cpp
===================================================================
--- /experimental/Threading/Threading/ChannelWorker.cpp	(revision 420)
+++ /experimental/Threading/Threading/ChannelWorker.cpp	(revision 420)
@@ -0,0 +1,64 @@
+#include "ChannelWorker.h"
+#include <osg/Notify>
+
+
+ChannelWorker::ChannelWorker(int numThreads, OpenThreads::Barrier& syncBarrier)
+ : _numThreads(numThreads), _syncBarrier(syncBarrier), _done(false)
+{
+	OSG_ALWAYS<<"ChannelWorker instantiated."<<std::endl;
+}
+
+ChannelWorker::~ChannelWorker()
+{
+	cancel();
+}
+
+void ChannelWorker::run()
+{
+	OSG_ALWAYS<<"ID "<<getThreadId()<<" running!"<<std::endl;
+
+	// Do the work
+	int i=0;
+	do
+	{
+		OSG_ALWAYS<<"ID "<<getThreadId()<<" :: itr "<<i++<<std::endl;
+
+		for(int i=0;i<100;i++)
+		OSG_ALWAYS<<"";
+
+	} while (!testCancel() && !_done);	// repeat as long it is canceld or set as Done
+
+
+	//_syncBarrier.block(_numThreads);  // Sync the threads.
+
+}
+
+void ChannelWorker::setDone(bool done)
+{
+	_done = done;
+}
+
+int ChannelWorker::cancel()
+{
+    OSG_ALWAYS<<"Cancelling ChannelWorker "<<this<<" isRunning()="<<isRunning()<<std::endl;
+
+    if( isRunning() )
+    {
+        _done = true;
+
+        OSG_ALWAYS<<"   Doing cancel "<<this<<std::endl;
+
+        // then wait for the the thread to stop running.
+        while(isRunning())
+        {
+            // commenting out debug info as it was cashing crash on exit, presumable
+            // due to OSG_NOTIFY or std::cout destructing earlier than this destructor.
+            OSG_ALWAYS<<"   Waiting for ChannelWorker to cancel "<<this<<std::endl;
+            OpenThreads::Thread::YieldCurrentThread();
+        }
+    }
+
+    OSG_ALWAYS<<"  ChannelWorker::cancel() thread cancelled "<<this<<" isRunning()="<<isRunning()<<std::endl;
+
+    return 0;
+}
Index: /experimental/Threading/Threading/ChannelWorker.h
===================================================================
--- /experimental/Threading/Threading/ChannelWorker.h	(revision 420)
+++ /experimental/Threading/Threading/ChannelWorker.h	(revision 420)
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <osg/Referenced>
+#include <OpenThreads/Thread>
+#include <OpenThreads/Barrier>
+
+
+class ChannelWorker : public osg::Referenced, public OpenThreads::Thread
+{
+public:
+	ChannelWorker(int numThreads, OpenThreads::Barrier& syncBarrier) ;
+	~ChannelWorker();
+	virtual void run();
+	virtual int cancel();
+	
+	void setDone(bool done);
+	bool getDone() const { return _done; }
+
+private:
+	int _numThreads;
+	bool _done;
+	OpenThreads::Barrier& _syncBarrier;
+};
Index: /experimental/Threading/Threading/SimHost.cpp
===================================================================
--- /experimental/Threading/Threading/SimHost.cpp	(revision 420)
+++ /experimental/Threading/Threading/SimHost.cpp	(revision 420)
@@ -0,0 +1,79 @@
+#include "SimHost.h"
+#include <osg/Notify>
+
+#include <OpenThreads/Thread>
+#include <OpenThreads/Barrier>
+
+// System includes
+#include <cassert>
+
+#ifdef _WIN32
+#include <process.h>
+#define getpid() _getpid()
+#else
+#include <unistd.h>
+#endif 
+
+// App includes
+
+
+SimHost::SimHost()
+{
+	OSG_ALWAYS<<"SimHost instantiated."<<std::endl;
+}
+
+SimHost::~SimHost()
+{
+	_channelWorker.clear();
+}
+
+void SimHost::initialize()
+{
+	int numThreads = 6+1;	// 6 channels and one main thread
+	OpenThreads::Barrier syncBarrier;
+
+	// Create ChannelWorkers
+	OSG_ALWAYS<<"Creating ChannelWorkers..."<<std::endl;
+	for(int i=0; i<numThreads-1; ++i)
+	{
+		osg::ref_ptr<ChannelWorker> worker = new ChannelWorker(numThreads, syncBarrier);
+		_channelWorker.push_back(worker);
+	}
+	OSG_ALWAYS<<"...done."<<std::endl;
+
+	// Setup Threading
+	OSG_ALWAYS << "Root Thread ID: " << getpid() << std::endl;
+
+	OSG_ALWAYS<<OpenThreads::GetNumberOfProcessors()<<" CPUs found, using "<<(numThreads)<<" of them concurrently."<<std::endl;
+	OpenThreads::Thread::SetConcurrency( numThreads );	// Only supported by pthread implementation, otherwise ignored
+
+	OpenThreads::Thread::Init();
+	
+}
+
+void SimHost::run()
+{
+	// Launch threads
+    for(int i=0;i<static_cast<int>(_channelWorker.size());++i)
+	{
+		int status;
+			
+		//thread->addObserver(&observer);
+		//thread->setStackSize(1024*256);
+		status = _channelWorker[i]->start();
+		assert(status == 0);
+	}
+
+	// Do something in the main thread
+	for(int i=0;i<10000000;i++)
+		OSG_ALWAYS<<"";
+	
+	// Signal threads to finish
+    for(int i=0;i<static_cast<int>(_channelWorker.size());++i)
+	{
+		_channelWorker[i]->setDone(true);
+		//_channelWorker[i]->cancel();		// Seems to be wrong
+	}
+
+	//syncBarrier.block(numThreads);  // Block until all threads are ready
+}
Index: /experimental/Threading/Threading/SimHost.h
===================================================================
--- /experimental/Threading/Threading/SimHost.h	(revision 420)
+++ /experimental/Threading/Threading/SimHost.h	(revision 420)
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <vector>
+#include <osg/Referenced>
+#include <osg/ref_ptr>
+
+#include "ChannelWorker.h"
+
+
+class SimHost :	public osg::Referenced
+{
+public:
+	SimHost();
+	~SimHost();
+
+	void initialize();
+	void run();
+
+private:
+	std::vector<osg::ref_ptr<ChannelWorker> > _channelWorker;
+
+};
Index: /experimental/Threading/Threading/Threading.vcproj
===================================================================
--- /experimental/Threading/Threading/Threading.vcproj	(revision 420)
+++ /experimental/Threading/Threading/Threading.vcproj	(revision 420)
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9,00"
+	Name="Threading"
+	ProjectGUID="{0DA5F800-C727-4724-8FEE-4787703ED9B6}"
+	RootNamespace="Threading"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				InlineFunctionExpansion="0"
+				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="$(OSG_ROOT)\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="false"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="osgd.lib OpenThreadsd.lib"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="$(OSG_ROOT)\lib"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="$(OSG_ROOT)\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				MinimalRebuild="false"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="osg.lib OpenThreads.lib"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="$(OSG_ROOT)\lib"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Quelldateien"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\ChannelWorker.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\main.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\SimHost.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Headerdateien"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\ChannelWorker.h"
+				>
+			</File>
+			<File
+				RelativePath=".\SimHost.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Ressourcendateien"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /experimental/Threading/Threading/main.cpp
===================================================================
--- /experimental/Threading/Threading/main.cpp	(revision 420)
+++ /experimental/Threading/Threading/main.cpp	(revision 420)
@@ -0,0 +1,22 @@
+// Threading Test
+
+// OSG includes
+#include <osg/Notify>
+#include <osg/ref_ptr>
+
+#include "SimHost.h"
+
+int main( int argc, char **argv )
+{
+
+	// Create osgVisual::SimHost
+	OSG_ALWAYS<<"Creating SimHost..."<<std::endl;
+	osg::ref_ptr<SimHost> simulationHost = new SimHost();
+	OSG_ALWAYS<<"...done."<<std::endl;
+
+	//Start it
+	simulationHost->initialize();
+	simulationHost->run();
+
+    return 0;
+}
