• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ThreadPoolExecutor question

 
Chris Gage
Greenhorn
Posts: 17
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although I have been doing Java as long as it has been around, I have never done any multi-threaded code, so here is a question that has been worrying me...

I am using a ThreadPoolExecutor to read HTML pages from an ancient web site created about 12 years ago, and reformat them from HTML3 to XML/XSLT. Each page read from the site is queued for reformatting, but also has links to other pages. As a consequence, the thread itself needs to add new pages to the queue. Is there anything dangerous about the thread queuing new requests? My greenness with java.util.concurrent makes me cautious.

truebrit
 
Henry Wong
author
Marshal
Pie
Posts: 21185
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There is nothing unsafe with queuing new requests in a threaded manner. The queue is threadsafe.

The only danger is if the new requests interact with the old request -- the executor doesn't protect the tasks from each other (but that is true, and must be dealt with, with any task).

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic