Results 1 to 2 of 2
  1. #1
    Azuki is offline Member
    Join Date
    Mar 2013
    Posts
    7
    Rep Power
    0

    Default Is it possible to execute the code by multiple threads simultaneously?

    Java Code:
    public class Counter
    {
    	protected long count = 0;
    
    	public void add (long value)
    	{
    		this.count = this.count + value;
    	}
    }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    654
    Rep Power
    1

    Default Re: Is it possible to execute the code by multiple threads simultaneously?

    Sure. But the results will be non-deterministic (and most likely not what you want). Didn't you already post a similar question? Why don't you just write some code and call this function in mutiple threads?

    Jim
    The Java™ Tutorial
    YAT -- Yet Another Typo

Similar Threads

  1. Two threads doesn't work simultaneously
    By przenica in forum Threads and Synchronization
    Replies: 3
    Last Post: 01-16-2011, 02:39 PM
  2. Executing two threads simultaneously.
    By Onra in forum New To Java
    Replies: 5
    Last Post: 04-05-2010, 08:03 PM
  3. Multiple persistance unit simultaneously, issue.
    By afrodom in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 03-06-2010, 05:04 PM
  4. Why my threads don't run simultaneously?
    By Gilvan Justino in forum New To Java
    Replies: 7
    Last Post: 01-16-2010, 01:43 AM
  5. Because Quartz configured execute 3 threads?
    By Zero2009 in forum Other IDEs
    Replies: 0
    Last Post: 07-23-2009, 09:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •