Hi,

I have to admit I didn't test JaQu with multiple threads. I found a
problem: the static map Db.TOKENS is not synchronized currently, this
is a bug. I will fix it.

If you are interested to understand how JaQu works - well, it is hard
to understand, I know. If you are interested please tell me, I will
try to explain (and document) it.

> Can a single "p" instance be concurrently shared by multiple threads if its
> just a "template" object ?

"p" must only be initialized by one thread (this is done in
"db.from(p)"). After that, you can use "p" by multiple threads,
because the tokens don't change.

> I see that it holds counts(?) after executing queries.

It holds unique objects to identify the table and column name. The
value is not significant.

> Can anyone comment on the TOKEN WeakHashmap in the Db class?

It's a WeakIdentityHashMap, not a WeakHashMap. See the javadocs for
this class. It holds unique tokens that are generated by functions
such as Function.sum(..) in
"db.from(p).select(Function.sum(p.unitPrice))". The unique objects
(tokens) are used to identify the function object. The actual value is
not significant (it might as well be zero).

> Are there any concerns there about thread safety or garbage collection with 
>it?

Tokens are only garbage collected if they are no longer referenced.
This part is thread-safe once the Db.TOKENS map is synchronized.

Regards,
Thomas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to