Blog about programming and new technologies in general I've created for myself, to memorize briliant solutions of problems, my own parts of code written previously and some general ideas of workarounds. You can find here Python, Java, JavaScript, C++, Django, jQuery.
June 11, 2010
Threads in Java
"Dining Philosophers" problem solved with Java and Semaphores.
import java.util.concurrent.Semaphore;
import java.util.Random;
import java.util.Vector;
public class Philosopher extends Thread
{
private static final Random rand = new Random();
private static int event=0;
private static String binary="";
private int id;
private Semaphore sem;
private static Vector
No comments:
Post a Comment