Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static Variables/Methods and Threads

Status
Not open for further replies.

LukeJW

Programmer
Jul 15, 2004
7
US
Hi, I haven't found any concrete answer to this and I'm wondering if someone could clear it up for me. Maybe it's just too obvious.

How are static variables and methods handled between threads? Between separate applications running concurrently?

For example, I have a static library I use in several applications. If I run two of them at the same time and one application modifies a static variable, will the other application see this change? My intuition is that it would not. My guess is that all threads in a single application see the same static variables, but a different application runs in it's own memory space and does not see any of these changes.

Thanks a lot!
 
LukeJW,

Yes, static variables can be used as a communicaion between different threads, but only within the same application.

To communicate between separate applications you can use RMI (but it's not usual to do this in the same machine), or you can use sockets to connect the to applications and transmit data using a protocol like TCP.

---
There is no Knowledge that is not power
---
 
Alright, sounds good. Thanks for the reponse!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top