SWT Thread & Static class [message #466915] |
Thu, 19 January 2006 07:14 |
Eclipse User |
|
|
|
Originally posted by: doubleletter.gmail.com
Hi,
I have two threads in my application, one of them <b>the SWT thread</b>, both of which access an <b>abstract</b> class with <b>static</b> variables.
Some of these variables are <b>Vectors</b>
The SWT thread will add elements to this vector, and the other thread will read them.
My question is, is there an issue of resource deadlock between the two threads ? Do I need to read/write from this vector in a synchronized block ?
Thanks in advance,
Regards,
Ahsan
|
|
|
Re: SWT Thread & Static class [message #466934 is a reply to message #466915] |
Thu, 19 January 2006 14:37 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Not normally because java.util.Vector is already synchronized. Only one
thread at a time can access it.
However, if your unit of work is more then just an add (i.e. if it is a
get followed by an add, then the get/add needs to be one unit of work)
you will need to sync around that using the vector itself as the sync
object.
Ahsan wrote:
> Hi,
>
> I have two threads in my application, one of them <b>the SWT thread</b>, both of which access an <b>abstract</b> class with <b>static</b> variables.
>
> Some of these variables are <b>Vectors</b>
>
> The SWT thread will add elements to this vector, and the other thread will read them.
>
> My question is, is there an issue of resource deadlock between the two threads ? Do I need to read/write from this vector in a synchronized block ?
>
> Thanks in advance,
>
> Regards,
>
> Ahsan
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.02799 seconds