Created
July 29, 2019 08:43
-
-
Save zarinfam/3f2dd9f8bc561dd4e935e1cfea0c7659 to your computer and use it in GitHub Desktop.
Created with Copy to Gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PrintTask { | |
| public static final String RESULT_SUCCESS = "SUCCESS_PRINT"; | |
| public static final String RESULT_FAILURE = "FAILURE_PRINT"; | |
| public static final String RESULT_TIMEOUT = "TIMEOUT_PRINT"; | |
| public static final String RESULT_NOTHING = "NOTHING_RESULT"; | |
| private String result = RESULT_NOTHING; | |
| public void getResult() throws PrintingException { | |
| while (result.equals(RESULT_NOTHING)) { | |
| synchronized (this) { | |
| try { | |
| wait(); | |
| } catch (Exception e) { | |
| throw new PrintingException(e); | |
| } | |
| } | |
| } | |
| if (result.equals(RESULT_SUCCESS)) { | |
| return; | |
| } | |
| throw new PrintingException(result); | |
| } | |
| public void setResult(String result) { | |
| this.result = result; | |
| synchronized (this) { | |
| notify(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment