Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Thread & Static class
SWT Thread & Static class [message #466915] Thu, 19 January 2006 07:14 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:SWT Group with no title -- can I make the background color consistent?
Next Topic:Transparent
Goto Forum:
  


Current Time: Sun May 26 22:58:23 GMT 2019

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

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

Back to the top