File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes Is Velocity thread safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Is Velocity thread safe?" Watch "Is Velocity thread safe?" New topic

Is Velocity thread safe?

Jayesh A Lalwani
Saloon Keeper

Joined: Jan 17, 2008
Posts: 2746

We have a Velocity Helper class that wraps Velocity engine for processing templates. The helper method is basically this

The thing is VelocityEngine is not really a lightweightt object, and I wanted to see if we can avoid creating an engine eveytime. In my thread dumps I see it loading and parsing some resources from classpath. This creates memory issues in JBoss 5.1 because VelocityEngine ends up calling CFS which has memory leaks. That is a whole another issue of course, but frequent creation of VelocityEngine instances excaberates the JBoss memory leaks. We are going to explode our war so we don;t use VFS.

So, I was wondering if I can just have one instance of VelocityEngine? Is it thread safe?
I agree. Here's the link:
subject: Is Velocity thread safe?
It's not a secret anymore!