I am currently creating a program that utilizes multithreading. In each thread, it appends to a TextArea
. I've come upon an error that I believe is due to multiple threads attempting to append to the TextArea at once. I am unable to switch to just using .setText()
because of the bug where the textProperty listener does not notice a change when using the .setText()
method. I'm relatively new to multithreading and apolgize if anything I said doesn't make sense, feel free to leave a comment for clarification.
Here is the code:
else console.appendText("\nfailure - " + arrays[finalJ][i] + ":" + word);
And the exception:
Exception in thread "Thread-6" Exception in thread "Thread-4" java.lang.IndexOutOfBoundsException: Index 94 out of bounds for length 94 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.base/java.util.Objects.checkIndex(Objects.java:359) at java.base/java.util.ArrayList.get(ArrayList.java:427) at javafx.controls/javafx.scene.control.TextArea$TextAreaContent.get(TextArea.java:130) at javafx.controls/javafx.scene.control.TextArea$TextAreaContent.get(TextArea.java:311) at javafx.controls/javafx.scene.control.TextArea$TextAreaContent.get(TextArea.java:88) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.get(TextInputControl.java:1386) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.get(TextInputControl.java:1370) at javafx.base/javafx.beans.binding.StringExpression.getValueSafe(StringExpression.java:68) at javafx.controls/javafx.scene.control.skin.TextAreaSkin.lambda$new$16(TextAreaSkin.java:348) at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:348) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.fireValueChangedEvent(TextInputControl.java:1459) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.markInvalid(TextInputControl.java:1463) at javafx.controls/javafx.scene.control.TextInputControl$TextProperty.controlContentHasChanged(TextInputControl.java:1402) at javafx.controls/javafx.scene.control.TextInputControl.lambda$new$0(TextInputControl.java:146) at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80) at javafx.controls/javafx.scene.control.TextArea$TextAreaContent.insert(TextArea.java:218) at javafx.controls/javafx.scene.control.TextInputControl.replaceText(TextInputControl.java:1264) at javafx.controls/javafx.scene.control.TextInputControl.updateContent(TextInputControl.java:572) at javafx.controls/javafx.scene.control.TextInputControl.replaceText(TextInputControl.java:564) at javafx.controls/javafx.scene.control.TextInputControl.insertText(TextInputControl.java:486) at javafx.controls/javafx.scene.control.TextInputControl.appendText(TextInputControl.java:476) at com.example.encryptionraw/com.example.encryptionraw.HelloController.lambda$runSoloBrute$4(HelloController.java:247)