+1  A: 

Polling is independent of the protocol you use to implement the client and server.

A client polls by looping endlessly. Inside the loop there's a request to the server for information. The server sends either the desired information or a "not ready" message back. The client does its thing and waits until the next request needs to be sent.

If you happen to choose RMI, it means an RMI client and server. But the polling mechanism is the same regardless.

Break the problem into pieces - it'll be easier to think about and solve that way.

Forget about polling to start. Can you write an RMI server, start it up, and create a separate client to make a single request? If you can do that, then you put it inside a loop with a sleep to implement the delay and you're done.

duffymo
thanks,i pasted the code for better picture of what i m doing if i m wrong somewhere in using right terminologies then please pardon.
Static Void Main
There's far too much stuff going on here. Simplify - Can you do the simple thing that I suggested? No UI, no threads - just create a server, create a client, and make a connection. Start with an interface for the server, because that expresses what the client would like to get back from the server and what the server requires to be passed. I'm not going to read your code. I've given you a pretty good picture. Now it's up to you.
duffymo
thanks but i thought u r talking about implementing client and server communication with RMI, and i thought i m beyond that stage as i already mentioned i have this design which is based on callbacks and it is also successful for turn based games but i have now problem in this case of animation when multiple clients executing the same method which is move repeatedly and i want that when that move method is already called by one client then there is no need that other client call that method which is causing the ball moves faster and faster.
Static Void Main
"How Polling mechanism can be realized with RMI?" - that's the question I'm answering.
duffymo
i mean that what you r saying i m almost doing that,if not then where am i wrong in following the idea u gave that's why i shown the code.
Static Void Main
A: 

I don't belive you can implement a callback via Java RMI. You need to either setup polling as you have suggested, or make your "client" RMI servers can you can send message to them directly.

How could you do this differently? I would suggest using JMS messaging to send command objects to the clients, this would handle all the distribution for you.

Peter Lawrey
thanks but how you will look at above, when that is not callback with RMI. i have no other option than RMI.
Static Void Main
When you pass an object as an argument, it is serialized on the client and deserialised on the server. A copy of that object is created. If you call methods on the copy they many appear to work,, but they won't call the orginal. I have implemented systems where this callback does a reverse proxy back to the client (using a custom RMI I wrote) , but I have never seen this work with standard RMI.
Peter Lawrey
i thought the problem you r referring to;i m suffering from that problem i have created a serialized object (ball), whose methods i m calling but some of methods seems not working like, i have 4 balls and i m setting the color and radius different, but all balls having same radius and color as the first ball,i don't know why this problem is there, and don't know whether is problem is coming because of issue you talked about.what is custom RMI if u can talked about, i created an application and now want to optimized that and generic model/template,but i m worried about the concerns i discussed.
Static Void Main
how much work would you expect? when u have to extract/make really simple network library/API for small scale real time game/simulation from RMI application, i created an application but is it nothing to achieve this goal?.
Static Void Main
What do you see when you debug your program with a debugger. This should show you exactly what is happen on each line to what object. BTW calling system exit without reporting an error or exception is a very bad idea. it means your application could die and you would have no idea/indication why.
Peter Lawrey
if you shed light on the questions i asked, i would be really glad =)
Static Void Main
Put simply you have a bug in your program and the fastest way to find and fix it is to use a debugger, that is what it is for. You are the only one which has all your code andd understanding of what you expect it to do. If you don't use a debugger regularly, you should learn to.
Peter Lawrey