Yes On Wed, Feb 27, 2008 at 3:56 AM, <[EMAIL PROTECTED]> wrote:
> On Feb 26, 7:56 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R <[EMAIL PROTECTED]> > > > escribió: > > > > > Hai, > > > > > Is it possible to share a single variable between multiple > > > threads. For eg: > > > > > Class A: > > > thread_init() > > > > > def run(): > > > fun1() > > > > > def fun(): > > > ........ assume some arithmatic operation is going on according to > the > > > input given and each fun will *give different output* > > > ......... > > > > Store the result inside the thread object; that is, in run, self.result= > > fun1(...) > > > > > Now 10 Thread will be running and each thread will have there > individual > > > output. > > > > > Here is the problem now i want the sum of output of all the > > > function. > > > > From your code I imagine you have a list of Thread instances; > > > > global_result = sum([t.result for t in list_of_threads]) > > > > -- > > Gabriel Genellina > > You can always hash the thread id: results[get_ident()]= result. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://search.goldwatches.com/?Search=Movado+Watches http://www.jewelerslounge.com http://www.goldwatches.com
-- http://mail.python.org/mailman/listinfo/python-list