15,000 Jobs Available in:
Java, ASP, C#, PHP, SQL, SAP, MySQL and many more.
- Class Quick -
The moose likes Threads and Synchronization and the fly likes Multiple Thread allow to change single variable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Multiple Thread allow to change single variable" Watch "Multiple Thread allow to change single variable" New topic
Author

Multiple Thread allow to change single variable

Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
Hi All,

I am having a small doubt in Threads. In my application, I am creating a ArryList in ClassA, adding 100 different values. Now I am passing this ArrayList to ClassB. Here, creating 'n' number of threads. All the threads are making some chages on the same ArrayList. If one thread made any changes, It should reflect to another.

Can any one Help me for this condition. Thanks.

Regards,
Prabhakaran


Regards,
Prabhakaran.N
Siva Arun
Greenhorn

Joined: Feb 23, 2010
Posts: 28
Try Vector Instead of ArrayList


"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 25060
To expand on what Siva Arun said, that sounds like a synchronisation problem, that changes are made at the same time by your many threads.
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 17259

Let's move this to Threads and Synchronization.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
Thanks Guys..!! I got the result.
 
 
subject: Multiple Thread allow to change single variable
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture