Index: trunk/FACT++/scripts/doc/Thread.js
===================================================================
--- trunk/FACT++/scripts/doc/Thread.js	(revision 16099)
+++ trunk/FACT++/scripts/doc/Thread.js	(revision 16102)
@@ -35,4 +35,8 @@
  *    A function which is executed aftr the initial timeout.
  *
+ * @param {Object} [_this]
+ *    An object which will be the reference for 'this' in the function call.
+ *    If none is given, the function itself will be the 'this' object.
+ *
  * @throws
  *    <li> If number or type of arguments is wrong
@@ -43,5 +47,5 @@
  *    handle.kill();
  */
-function Thread(timeout, function)
+function Thread(timeout, function, _this)
 {
     /**
Index: trunk/FACT++/scripts/doc/v8.js
===================================================================
--- trunk/FACT++/scripts/doc/v8.js	(revision 16099)
+++ trunk/FACT++/scripts/doc/v8.js	(revision 16102)
@@ -31,5 +31,5 @@
  * main purpose of a loop is, e.g., to wait for something to happen.
  *
- * @param {Integer} [milliseconds]
+ * @param {Integer} milliseconds
  *     Number of millliseconds until the timeout. Note that even 0
  *     will execute the function at least once. If the timeout
@@ -37,5 +37,5 @@
  *     be returned in case of a timeout.
  *
- * @param {Function} [func]
+ * @param {Function} func
  *     A function. The function defines when the conditional to end
  *     the timeout will be fullfilled. As soon as the function returns
@@ -43,6 +43,10 @@
  *     timeout is stopped and its return value is returned.
  *
+ * @param {Object} [_this]
+ *    An object which will be the reference for 'this' in the function call.
+ *    If none is given, the function itself will be the 'this' object.
+ *
  * @param [. . .]
- *     Any further argument will be passed to the function.
+ *     Any further argument will be passed as argument to the function.
  *
  * @returns
Index: trunk/FACT++/src/InterpreterV8.cc
===================================================================
--- trunk/FACT++/src/InterpreterV8.cc	(revision 16099)
+++ trunk/FACT++/src/InterpreterV8.cc	(revision 16102)
@@ -141,4 +141,7 @@
         return ThrowException(String::New("Argument 1 not a function."));
 
+    if (args.Length()>2 && !args[2]->IsObject())
+        return ThrowException(String::New("Argument 2 not an object."));
+
     const int32_t timeout = args[0]->IsNull() ? 0 : args[0]->Int32Value();
     const bool    null    = args[0]->IsNull();
@@ -148,12 +151,14 @@
     Handle<Function> func = Handle<Function>::Cast(args[1]);
 
-    Handle<Value> argv[args.Length()-2];
-    for (int i=0; i<args.Length()-2; i++)
-        argv[i] = args[i+2];
+    const int nn = args.Length()==2 ? 0 : args.Length()-3;
+
+    Handle<Value> argv[nn];
+    for (int i=0; i<nn; i++)
+        argv[i] = args[i+3];
 
     Time t;
     while (1)
     {
-        const Handle<Value> rc = func->Call(func, args.Length()-2, argv);
+        const Handle<Value> rc = args.Length()<3 ? func->Call(func, nn, argv) : func->Call(args[2]->ToObject(), nn, argv);
         if (rc.IsEmpty())
             return Undefined();
@@ -179,5 +184,5 @@
 }
 
-void InterpreterV8::Thread(int &id, Persistent<Function> func, uint32_t ms)
+void InterpreterV8::Thread(int &id, Persistent<Object> _this, Persistent<Function> func, uint32_t ms)
 {
     const Locker lock;
@@ -206,7 +211,14 @@
     const bool rc = ms==0 || !ExecuteInternal("v8.sleep("+to_string(ms)+");").IsEmpty();
     if (rc)
-        func->Call(func, 0, NULL);
+    {
+        if (_this.IsEmpty())
+            func->Call(func, 0, NULL);
+        else
+            func->Call(_this, 0, NULL);
+    }
 
     func.Dispose();
+    _this.Dispose();
+
     fThreadIds.erase(id_local);
 
@@ -220,6 +232,6 @@
         return ThrowException(String::New("Thread must be called as constructor."));
 
-    if (args.Length()!=2)
-        return ThrowException(String::New("Number of arguments must be two."));
+    if (args.Length()!=2 && args.Length()!=3)
+        return ThrowException(String::New("Number of arguments must be two or three."));
 
     if (!args[0]->IsUint32())
@@ -229,4 +241,7 @@
         return ThrowException(String::New("Argument 1 not a function."));
 
+    if (args.Length()==3 && !args[2]->IsObject())
+        return ThrowException(String::New("Argument 2 not an object."));
+
     //if (!args.IsConstructCall())
     //    return Constructor(args);
@@ -236,10 +251,13 @@
     Handle<Function> handle = Handle<Function>::Cast(args[1]);
 
-    Persistent<Function> func = Persistent<Function>::New(handle);
+    Persistent<Function> func =  Persistent<Function>::New(handle);
+    Persistent<Object> _this;
+    if (args.Length()==3)
+        _this = Persistent<Object>::New(args[2]->ToObject());
 
     const uint32_t ms = args[0]->Uint32Value();
 
     int id=-2;
-    fThreads.push_back(thread(bind(&InterpreterV8::Thread, this, ref(id), func, ms)));
+    fThreads.push_back(thread(bind(&InterpreterV8::Thread, this, ref(id), _this, func, ms)));
     {
         // Allow the thread to lock, so we can get the thread id.
Index: trunk/FACT++/src/InterpreterV8.h
===================================================================
--- trunk/FACT++/src/InterpreterV8.h	(revision 16099)
+++ trunk/FACT++/src/InterpreterV8.h	(revision 16102)
@@ -65,5 +65,5 @@
     v8::Handle<v8::Value> ExecuteInternal(const std::string &code);
 
-    void Thread(int &id, v8::Persistent<v8::Function> func, uint32_t ms);
+    void Thread(int &id, v8::Persistent<v8::Object> _this, v8::Persistent<v8::Function> func, uint32_t ms);
 
     std::vector<std::string> ValueToArray(const v8::Handle<v8::Value> &val, bool only=true);
