Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ejercicios;
- import static es.urjc.etsii.code.concurrency.SimpleConcurrent.*;
- import es.urjc.etsii.code.concurrency.SimpleSemaphore;
- public class Ejer14 {
- static SimpleSemaphore semSinc;
- static SimpleSemaphore semN;
- static final int N_PROC = 4;
- public static void proc()
- {
- System.out.print("A");
- semN.release();
- if(semN.permits() < N_PROC)
- {
- semSinc.acquire();
- }
- else
- {
- semSinc.release(N_PROC-1);
- }
- System.out.print("B");
- }
- public static void main(String[] args) {
- semSinc = new SimpleSemaphore(0);
- semN = new SimpleSemaphore(0);
- createThreads(N_PROC,"proc");
- startThreadsAndWait();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement