There is an array with strings "A", "B" and "A, B" (there are many repeated). I need to make 2 threads A and B, each of which will independently output its strings in the correct order (as in the original array, general in any). Did I get it right, the best way to implement this is with wait() and notify()? As long as the lines correspond to the thread, output them, and after that put wait(), at that point the second thread starts outputting its lines before the same wait(). But I don't understand where to call notify.
upd: example:
for String[] arr = {"A", "A", "A, B", "B", "A", "B"}
I want output like
A A
A A
A B
B A
B B
A A
B or B
All "A" should be printed by Thread A, all "B" should be printed by Thread B. If the value in the array is common ("A, B"), then the order of printing is not important, but the letters must be after all the previous and before the next elements.