Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package trabalhoso;
- /**
- *
- * @author franc
- */
- public class SharedObj {
- private boolean estadoCancela = false; //True = Aberta, False = fechada
- private int codigo;
- private int flag;
- public synchronized void toggleCancela() {
- this.estadoCancela = !this.estadoCancela;
- }
- public synchronized boolean getEstadoCancela() {
- return this.estadoCancela;
- }
- public synchronized void setCodigo(int codigo) {
- this.codigo = codigo;
- this.flag = 1; //Activa a flag responsável por gerir o código introduzido
- }
- public synchronized int getCodigo() {
- return this.codigo;
- }
- public synchronized void setFlag(int flag) {
- this.flag = flag;
- }
- public synchronized int getFlag() {
- return this.flag;
- }
- public synchronized void aguarda() {
- try {
- this.wait();
- } catch (InterruptedException ie) {
- }
- }
- public synchronized void acordaTodas() {
- this.notifyAll();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement