This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Is it possible to execute the code by multiple thread simulataneously? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Is it possible to execute the code by multiple thread simulataneously?" Watch "Is it possible to execute the code by multiple thread simulataneously?" New topic
Author

Is it possible to execute the code by multiple thread simulataneously?

azuki ooh
Greenhorn

Joined: Nov 07, 2008
Posts: 20
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4164
    
  21

Is it possible to execute the code by multiple thread simulataneously?

Concurrently? Yes. Simultaneously? That depends on hardware and OS.


Steve
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Also note that for code like that, if the threads are sharing the same instance, then if you don't use proper synchronization, you may get undesirable results. For example, you could have 100 threads executing, and the count could end up at 1, or at 2, or at anything up to and including 100.
 
Consider Paul's rocket mass heater.
 
subject: Is it possible to execute the code by multiple thread simulataneously?
 
Similar Threads
String constructors and counting objects
Inheritance problem
JPA and static inner class, possible?
Problem with jsp:getProperty
String constructor