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
    Northern Virginia, United States
    Posts
    3,920
    Rep Power
    5

    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 JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

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