Advertisement
xickoh

Untitled

Jan 2nd, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package trabalhoso;
  7.  
  8. /**
  9. *
  10. * @author franc
  11. */
  12. public class SharedObj {
  13.  
  14. private boolean estadoCancela = false; //True = Aberta, False = fechada
  15. private int codigo;
  16. private int flag;
  17.  
  18. public synchronized void toggleCancela() {
  19. this.estadoCancela = !this.estadoCancela;
  20. }
  21.  
  22. public synchronized boolean getEstadoCancela() {
  23. return this.estadoCancela;
  24. }
  25.  
  26. public synchronized void setCodigo(int codigo) {
  27. this.codigo = codigo;
  28. this.flag = 1; //Activa a flag responsável por gerir o código introduzido
  29. }
  30.  
  31. public synchronized int getCodigo() {
  32. return this.codigo;
  33. }
  34.  
  35. public synchronized void setFlag(int flag) {
  36. this.flag = flag;
  37. }
  38.  
  39. public synchronized int getFlag() {
  40. return this.flag;
  41. }
  42.  
  43. public synchronized void aguarda() {
  44. try {
  45. this.wait();
  46. } catch (InterruptedException ie) {
  47. }
  48. }
  49.  
  50. public synchronized void acordaTodas() {
  51. this.notifyAll();
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement