Re: "shared" object



Darko Topolsek wrote:
public class Counter extends .... {
    public Counter() {
        super(...);
    }

    private void updateCounter() {
        count += 1;
    }
Shouldn't this be public? How else can it be accessed from the outside? Or did i miss some trick? :)

[...]

Thanks for responding, but this doesn't quite do the trick. I think i have to elaborate on what i want. From what i wrote previously, i don't think it came out clearly.


I have a package, foo, containing the Counter class. Now i have a class, A, which does: import foo.Counter;

A has a main method, which starts an instance of itself, wrapped in a Thread. The Thread works as a ticker, counting the shared object Counter up one.

Now i start another instance of A, from another shell. Since this does the exact same thiing as the first A, it also imports foo.Counter. What i want is for the second instance to start counting from where the first instance was at when the second was started.

An example printout would be like this:

(Start A1, first instance of A, with java A)
A1: count: 1
A1: count: 2
A1: count: 3
(start A2, second instance of B, in another shell, with java A)
A2: count: 4
A1: count: 5
A2: count: 6
A1: count: 7

And so on...

From what i tried, A2 just starts counting from 1, and A1 just keeps counting.

Any suggestions on how to crack this one? :)

- Carsten H. Pedersen
.



Relevant Pages

  • Re: Search and Destroy.
    ... I'm convinced it's a Windows thing, primaril because FileLocatorPro ... I ran a second instance of Search (for the ... |>went back to the First Instance, deleted one file and the Second ...
    (microsoft.public.windowsxp.general)
  • Re: Search and Destroy.
    ... A temp file, one in use or non existent file is the most common reason ... |>went back to the First Instance, deleted one file and the Second Instance ... "Group Deletes" still report the same error. ...
    (microsoft.public.windowsxp.general)
  • Re: Passing arguments to a running application
    ... The second instance of your program is finding the first instance, ... WM_ACTIVATE to the first instance) and then exits. ... the first instance running, with whatever parameters it was initially ... Don't have it switch to ...
    (microsoft.public.pocketpc.developer)
  • Re: Calling procedure on another software
    ... >> The second instance should send a message to the first instance. ... > What you'll need to do is add command line support to the app. ... > Command$ variable will contain any command line params you send to an app. ...
    (microsoft.public.vb.general.discussion)
  • Re: Multiple modems on same machine for IVRS
    ... The first instance works perfectly. ... The second instance seems to initialize fine but fails when it goes to ...
    (microsoft.public.win32.programmer.tapi)