• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on thread

 
sanjana narayanan
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can someone explain me the different types of multithreading?

thanks,
sanjana
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't any particular set of "types of multithreading" that I'm aware of. The right answer would, I imagine, depend on what the instructor has taught you this quarter.
 
sanjana narayanan
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of my friend was interviewed on this topic and she couldn't answer it. I am just curious to know what it would be. I referred a couple of books on threads and they had no mention of it.
 
Mike Southgate
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implementing Runnable versus subclassing Thread maybe?

ms
 
Jeff Walker
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tough Computer Science type of question. Only related to Java because you can do concurrent programming in Java.
Here's my answer:

There are 4 main types of multithreading. They are:

1. Unrelated Multi-threaded programing.
It's tough to think of a decent industrial-strength example, but I suspect something like what servlets do would suffice. E.g. each servlet instance running in a separate thread servicing a different unrelated HTTP request. Threads never communicate and never share data of any kind. (Only if the session object is not used).

2. Related but Unsynchronized Multi-threaded programnming.
Threads are related, in that they work to solve a common overall problem, but do not touch each others data. E.g. Gaussian Elimination, or matrix multiplication, where multiple threads can operate on the same data structure and NEVER tred on each others toes, mainly because they never access the same exact data. (It's been awhile since i did GE or matrices, so, perhaps these aren't great examples?)

3. Mutually Exclusive Mutli-threaded programming.
Example: Any program that makes use of heavy use of synchronized code blocks or synchronized static methods, but doesn't care about the other threads and so there is no inter-thread communication going on. E.g. gui programs that must run the gui in a separate thread for immediate client response, while the model/business logic is performed in a separate daemon thread. Any program that uses daemon threads only, is a candidate.

4. Communicating Mutually Exclusive Mutli-threaded programming.
Example: Classic example is the Producer/Consumer program. Heavy use of synchronized code blocks as well as calls to wait() and notify(). JMS style messaging may be a decent example, if the messages are produced and consumed within the same application, but by different threads running within the same application. Each thread must communicate with the other threads by setting a flag somewhere to let the other threads know that a resource is available for access.

Jeff Walker
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic