• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find out whether given method is thread safe or not?  RSS feed

 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am bit confused. I am using Google SOAP for searching on Google. I want to search using multiple threads and want to add thread pooling concept in my application.

I am using doSearch () of GoogleSearch class to search on Google.

I want to know, is doSearch () thread safe?

How to find out whether given method is thread safe or not?
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not find out without seeing the source code. Isn't there any comment in the docs ? Don't they have a forum for this API ?


Pascal
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actualy you can't even be sure if you check out the libray source code because the server software could be written in a not thread safe manner e.g. by storing stuff in the HttpSession or ApplicationContext or static vars or instance references and so on.
('though i doubt that with google... after all they are able to manage two or three concurrent users with their search :-) )

so i would check the docs and ask in their forum.

And are you sure you need a Thread Pool ? Probably overhead. Just create the Threads as needed.

pascal
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well its true that without seeing the source code it would not be possible to determine whether the method is thread safe or not.
But I guess its thread safe.The reason being ; there is no need to store any data in class level variables.You pass the String parameter and probably get return a array of objects.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pascal Betz and Rahul for your reply.

I have posted on Google API Forum.

And you are right, Thread Pool can be avoided.
[ November 20, 2006: Message edited by: Chetan Parekh ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!