• Post Reply Bookmark Topic Watch Topic
  • New Topic

Concurrency in java.util.logging

 
Juan Tamayo
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I'm writing a simple Handler for the java logging API, so that I can write log messages using JDBC. I found an example in

http://www.developer.com/java/article.php/1468351

which is precisely what I need, except that it has no mention to concurrency issues. My question is, should a Handler object be thread safe? if so, which methods can be called from multiple threads? or are all calls made to a Handler object made from the same thread?

Thanks for your help,

Juan Tamayo
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the methods in the handler class are supposed to be thread safe. All JDK provided handlers, eg: FileHandler, StreamHandler synchronize the entire methods.
Since JDBC connection is not thread safe so, you have to put external synchronization in your handler.
 
Juan Tamayo
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right, they're all synchronized. Thanks for the help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!