Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RAP and ThreadLocals
RAP and ThreadLocals [message #527610] Thu, 15 April 2010 17:56 Go to next message
Benjamin Wolff is currently offline Benjamin WolffFriend
Messages: 136
Registered: July 2009
Senior Member
Hi,

i have s question regarding RAP applications and ThreadLocal objects.
At some spots in my application, i use ThreadLocal objects to share these
objects between a user-session(thread). These objects are not synchronized
so i can't use them in a static way. A single object instance for every
object that uses it is too much memory wasted. So i choose the compromise
to use one object per thread thus avoiding expensive synchronization and
not wasting memory.
Is this approach RAP conform?? I know there is a SessionSingletonBase class,
which i also use. But in this case, this has nothing to do with RAP etc.,
so i don't want to build a dependency to RAP API.
For example, i'm using this for SimpleDateFormat and several NumberFormat
instances, which are used in my domain model.
Since i'm not so deep into RAP threading internals, i just wanted to make
sure, that i shouldn't expect any unpredicted behaviour?!
Can in assume, that there is always one user(ui)-thread in RAP unless i create
other threads manually??

please great RAP folks, let thy light of wisdom shine down upon me, so it may
blind my unawareness =))

Greetings,
-ben
Re: RAP and ThreadLocals [message #527693 is a reply to message #527610] Fri, 16 April 2010 07:02 Go to previous message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi Benjamin,

as RAP uses the read and dispatch model from SWT you can be sure, that
most of your code that runs within a concrete session context always
runs in the same UIThread.

The only exception I am aware of are ServiceHandlers - they run in a
different thread but still in a session context.

Security frameworks often use a thread-based authentication - in this
case, authenticating the UIThread once on sessions startup (e.g.
#createUI) is sufficient (As an example for the usage of ThreadLocals).

Regards,
Stefan.

Benjamin Wolff schrieb:
> Hi,
>
> i have s question regarding RAP applications and ThreadLocal objects.
> At some spots in my application, i use ThreadLocal objects to share these
> objects between a user-session(thread). These objects are not synchronized
> so i can't use them in a static way. A single object instance for every
> object that uses it is too much memory wasted. So i choose the compromise
> to use one object per thread thus avoiding expensive synchronization and
> not wasting memory.
> Is this approach RAP conform?? I know there is a SessionSingletonBase
> class,
> which i also use. But in this case, this has nothing to do with RAP etc.,
> so i don't want to build a dependency to RAP API.
> For example, i'm using this for SimpleDateFormat and several NumberFormat
> instances, which are used in my domain model.
> Since i'm not so deep into RAP threading internals, i just wanted to make
> sure, that i shouldn't expect any unpredicted behaviour?!
> Can in assume, that there is always one user(ui)-thread in RAP unless i
> create
> other threads manually??
>
> please great RAP folks, let thy light of wisdom shine down upon me, so
> it may
> blind my unawareness =))
>
> Greetings,
> -ben
Previous Topic:ArrayIndexOutOfBoundsException on startup with current CVS HEAD
Next Topic:Periodic activity for duration of session?
Goto Forum:
  


Current Time: Fri Apr 26 22:03:24 GMT 2024

Powered by FUDForum. Page generated in 0.04018 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top