I am running multiple instances of my own chess algorithm in Eclipse, having them play games against themselves. Each instance of the main class plays games against itself, so if I start two instances of the main class, two chess games will be played simultaneously. The two games should not conflict. However, I am getting unusual results. One instance is consistently winning. The other is consistently losing. Both main classes reference a number of other static classes. When multiple instances of the main class are running, do they share other static classes? Is it possible that one could conflict with the other, or affect its results?
Asked
Active
Viewed 55 times
-2
-
No static fields are shared between Java processes. – Michael Jul 28 '17 at 16:39
-
Is there any other way to explain my results? Could it be caused by patterns in Math.random()? – Daniel Williams Jul 28 '17 at 16:43
-
There's too many factors to say for sure, especially without seeing any code. – Michael Jul 28 '17 at 16:46
-
It's just occurred to me: what are you counting as a "win"? If each process plays a game with *itself*, the only potential winner *is* itself. – Michael Jul 28 '17 at 16:47
-
Are the instances of the main class actually in different processes from launching more than one, or are they living in the same JVM? – nitind Jul 28 '17 at 16:54
-
This question is far to difficult to answer without a deep dive in the code itself. – Deadron Jul 28 '17 at 17:00
-
The code itself shouldn't matter. I'm clicking the run button in Eclipse two times in a row, and neither instance is reading external files, so they should produce the same results. They are playing hundreds of games, so I would expect any use of Math.random() to even out. – Daniel Williams Jul 28 '17 at 17:08
-
@nitind, each instance shows up as a separate process in task manager, so I believe they are in separate JVMs. – Daniel Williams Jul 28 '17 at 17:11
-
1Most of the time, it *is* your code's fault in some way. – nitind Jul 28 '17 at 18:18
-
With whom are the processes playing? Against each other? How are they communicating, is there any mediator betwen them? – Petr Janeček Jul 28 '17 at 18:27
1 Answers
1
No, different JVMs running at the same time do not have anything in common, and don't conflict with each other.

nitind
- 19,089
- 4
- 34
- 43