• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is multi thread possible

 
Yuan Ye
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys.
I am using the model of a new instance of Data service per RMI connection. I am thinking even in this situation is it possible that one client(GUI) can invoke two method(two thread) of a Data instance concurrently? (For example, if a user request two tasks in a very short time.) Do I need write nodes in the GUI to forbid thus situation?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
I think this can only happen if, within the client GUI application, you create new threads to handle each user request.
This is a nice idea, as it stops the application from appearing to hang. But it is not necessary for this assignment.
If you do do this though, I think it would be a good idea to make sure that the client cannot initiate any other actions while waiting for the first to complete.
I would simply stop all other actions from being started. The logic and coding for which other actions might be acceptable is going to be quite complicated - certainly more than what is required for this assignment, and I doubt that the junior programmer will be too impressed reading through state tables.
Regards, Andrew
 
Yuan Ye
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Andrew.
Does that mean I should avoid presenting two event triggering buttons in one graphic interface? Since in Java each event handling is a independent thread, is that true? Thanks again.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, in fact Java is set up so that if you don't do anything to spawn any new threads yourself, each event is handled in the one and only event processing thread. So from the client perspective, all actions occur sequentially in a single thread, as Andrew indicated. On the server, thanks to the magic of RMI different method calls from the same single client may actually be handled by different threads. However, even if they're handled by different threads, they won't occur sequentially, because the client won't issue the next remote method call until it receives notification that the previous call has comleted successfully. (Again, this is handled by RMI; you don't really need to think about it.) So you will probably have multiple server threads per client - but no concurrent actions from the same client. (Of course, there may be lots of concurrent actions from other clients, which is where most of the fun comes from...(
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic