Rewrites the Screen, so that the main drawing code is multithreaded to some degree.
@@ -245,8 +245,28 @@ public class Screen extends Component {
components.forEach(component -> component.draw(this));
// Draw the screen onto the canvas:
- for (int row = 0 ; row < getHeight() ; row++) {
- super.getString(row).draw(gc, imageCache, row, offset);
+ final AsciiString[] strings = super.getStrings();
+
+ final Thread threadA = new Thread(() -> {
+ for (int row = 0; row < (getHeight() / 3); row++) {
+ strings[row].draw(gc, imageCache, row, offset);
+ }
+ });
+
+ final Thread threadB = new Thread(() -> {
+ for (int row = (getHeight() / 3); row < getHeight(); row++) {
+ strings[row].draw(gc, imageCache, row, offset);
+ }
+ });
+
+ threadA.run();
+ threadB.run();
+
+ try {
+ threadA.join();
+ threadB.join();
+ } catch(final InterruptedException e) {
+ e.printStackTrace();
}
// Draw layer components onto the screen:
