Advertisement
Guest User

thread

a guest
Jan 19th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1.  
  2.  
  3. Runnable firstRun = new Runnable(){
  4. @Override
  5. public void run(){
  6. try{
  7. for (int x = 100; x <= 1024; x+=100) {
  8. graphics.setColor(Color.red);
  9. graphics.drawOval(x, 100, 200, 200);
  10. Thread.sleep(1000);
  11. graphics.setColor(Color.white);
  12. graphics.drawOval(x, 100, 200, 200);
  13. }
  14. }catch(InterruptedException ex){
  15. ex.printStackTrace();
  16. }
  17. }
  18. };
  19. Thread firstThread = new Thread(firstRun );
  20.  
  21. Runnable secondRun= new Runnable(){
  22. @Override
  23. public void run(){
  24. try{
  25. for (int x = 100; x <= 1024; x+=100) {
  26. graphics.setColor(Color.red);
  27. graphics.drawOval(x, 100, 200, 200);
  28. Thread.sleep(1000);
  29. graphics.setColor(Color.white);
  30. graphics.drawOval(x, 100, 200, 200);
  31. }
  32. }catch(InterruptedException ex){
  33. ex.printStackTrace();
  34. }
  35. }
  36. };
  37. Thread secondThread = new Thread(secondRun);
  38.  
  39. Runnable thirdRun= new Runnable(){
  40. @Override
  41. public void run(){
  42. try{
  43. for (int x = 100; x <= 1024; x+=100) {
  44. graphics.setColor(Color.red);
  45. graphics.drawOval(x, 100, 200, 200);
  46. Thread.sleep(1000);
  47. graphics.setColor(Color.white);
  48. graphics.drawOval(x, 100, 200, 200);
  49. }
  50. }catch(InterruptedException ex){
  51. ex.printStackTrace();
  52. }
  53. }
  54. };
  55. Thread thirdThread= new Thread(thirdRun);
  56. firstThread.start();
  57. secondThread.start();
  58. thirdThread.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement