I want to make two programs. where program 1 will have a static collection and some getter/setter to access/update its values.
I want that program 2 should be able to access/call getter/setter of program1. so that static collection can be shared among many programs/process
*i dont want to engage any port.
You can’t just declare a variable static (or super-static) and expect it to be available in code outside of your program – it just doesn’t work that way. What you need is some sort of inter-process communication, and the possibilities are endless. To name a few:
– serialize / deserialize to and from a file (local or on the network)
– sockets (basically, you open a network connection between two ports on localhost)
– a database
– shared memory (whether this is possible depends on the OS)
Your OS of choice may offer other means, but the principle remains the same: whenever the variable changes, one application needs to notify the other.