I have tried these but it wasn't working with me, The code is: #include <v8.h> #include <pthread.h> using namespace v8; void* threadFunction(void*){ Isolate *isolate1 = Isolate::GetCurrent(); HandleScope handle_scope1(isolate1); Handle<Context> context1 = Context::New(isolate1); Context::Scope context_scope1(context1); Handle<String> source1 = String::NewFromUtf8(isolate1, "'Hi' + ', Sara'"); Handle<Script> script1 = Script::Compile(source1); Handle<Value> result1 = script1->Run(); String::Utf8Value utf81(result1); printf("%s\n", *utf81); return 0; } int main(int argc, char* argv[]) { Isolate* isolate = Isolate::GetCurrent(); HandleScope handle_scope(isolate); Handle<Context> context = Context::New(isolate); Context::Scope context_scope(context); pthread_t thread_id; pthread_create(&thread_id, NULL, &threadFunction,NULL); Handle<String> source = String::NewFromUtf8(isolate, "'Hello' + ', World!'"); Handle<Script> script = Script::Compile(source); Handle<Value> result = script->Run(); String::Utf8Value utf8(result); printf("%s\n", *utf8); return 0; }
and the command that I used to compile is g++ -Iinclude Two_threads.cpp -o Two_threads -Wl,--start-group out/native/obj.target/{tools/gyp/libv8_{base.ia32,snapshot},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt and to execute is ./Two_threads it was compiled without giving me any error but when I executed it i printed only hello world! "the javascript string of the main thread" and didn't print hi,Sara the javascript string of the single thread I have in the code. So, what is the problem? or what ? Thank you in advance On Fri, Jan 31, 2014 at 11:45 AM, Sara Abdelhameed < saraabdelhameed1...@gmail.com> wrote: > Thank you, and I'll try that now, wish it work with me. > > > On Fri, Jan 31, 2014 at 9:40 PM, Dmitry Lomov <dslo...@chromium.org>wrote: > >> >> >> >> On Fri, Jan 31, 2014 at 11:38 AM, Sara Abdelhameed < >> saraabdelhameed1...@gmail.com> wrote: >> >>> so, if I want to make very simple example such as having two threads >>> that each one run different script and don't depend on each other, and I >>> want them to be in parallel, so I must use two isolate, for every thread >>> there is one isolate and no need to use lock as the scripts are different >>> and independent from each other. is this right? >>> >> >> Yes that is correct. >> >> >>> >>> On Friday, January 31, 2014 11:23:28 AM UTC+2, Jochen Eisinger wrote: >>> >>>> There are two options: (1) use different isolates on each thread (then >>>> the scripts can run in parallel) and (2) use one isolate and use v8::Locker >>>> to lock the isolate before you use it (then only one thread at a time can >>>> execute scripts) >>>> >>>> best >>>> -jochen >>>> >>>> >>>> On Fri, Jan 31, 2014 at 9:51 AM, Sara Abdelhameed < >>>> saraabdel...@gmail.com> wrote: >>>> >>>>> Hello all, >>>>> does v8 engine support multithreaded application ? and could I run two >>>>> different javascript code in two different threads at the same time ? >>>>> >>>>> -- >>>>> -- >>>>> v8-users mailing list >>>>> v8-u...@googlegroups.com >>>>> >>>>> http://groups.google.com/group/v8-users >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "v8-users" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to v8-users+u...@googlegroups.com. >>>>> >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>> >>>> -- >>> -- >>> v8-users mailing list >>> v8-users@googlegroups.com >>> http://groups.google.com/group/v8-users >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "v8-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to v8-users+unsubscr...@googlegroups.com. >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- >> -- >> v8-users mailing list >> v8-users@googlegroups.com >> http://groups.google.com/group/v8-users >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "v8-users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/v8-users/oN_3tVBd3H4/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> v8-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.