This fixes a race condition between application and 'Print Job Thread' threads when printing.
The race condition occurs when application thread calls `endJob()`, which in effect sets the `jobDone` flag to true, and when the 'Print Job Thread' thread was in the `synchronized` block in `waitForNextPage()` at that time. The 'Print Job Thread' thread checks `jobDone` flag after exiting the `synchronized` block and, if it is true, skips the last page. In this fix, not only the `jobDone` is checked, but also that there is no other page to be printed. It was also needed to introduce a new flag 'jobCanceled', to skip the page if the printing was canceled by 'cancelJob()'. ------------- Commit messages: - 8295324: Fix skipping of pages when printing - 8295324: Apply patch with junit from the issue Changes: https://git.openjdk.org/jfx/pull/916/files Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=916&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8295324 Stats: 463 lines in 6 files changed: 444 ins; 0 del; 19 mod Patch: https://git.openjdk.org/jfx/pull/916.diff Fetch: git fetch https://git.openjdk.org/jfx pull/916/head:pull/916 PR: https://git.openjdk.org/jfx/pull/916