Sujee,

You are correct in creating a separate HTable instance in each thread. (HTable 
isn't thread safe, but since the scope is within the thread it works.)

You could use the HTablePool class, but I don't think its a better solution for 
what you are doing.

In your example it sounds like you're creating the connection in each thread 
and you're using it for the life of the thread/application.  So there's no real 
benefit in trying to create a pool of threads and then request a thread from 
the pool.

JMHO

-Mike


> From: su...@sujee.net
> Date: Tue, 23 Aug 2011 16:34:32 -0700
> Subject: question on HTablePool and threads
> To: hbase-u...@hadoop.apache.org
> 
> Hi all,
> 
> Right now I have a  java client program that accesses Hbase in multiple
> threads for read / write.  Each thread creates its own instance of HTable of
> the _same_ table.
> 
> I am looking into HTablePool class.  Not clear on if it is a correct/better
> choice for accessing the _same_ table with multiple threads.
> 
> Is this a valid  / thread-safe ?
> 
> create HtablePool in 'main'
> pass HTablePool instance to threads
> each thread does a  'htablepool.get(table)'
>     read / write to table
>     'htablepool.put (table) '  when done
> (all this is done within a single JVM)
> 
> thanks
> Sujee Maniyam
> http://sujee.net
                                          

Reply via email to