I've been lurking around various websites and reading up on many different threads over the past few days and I noticed that a few people were saying not to use Thread.sleep for various reasons that I can't currently remember.
I was wondering if it's alright to be using Thread.sleep() in this circumstance:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| class MessageDisplay { public MessageDisplay() { } public void typeWriterDisplay(String x, int y) { for (int i = 0; i < x.length(); i++) { System.out.print( x.charAt(i) ); try { Thread.sleep(y); } catch (Exception e) { e.printStackTrace(); } } } } |
I'm using it to display strings character-by-character with a small delay between characters.