This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function try_to_win() { | |
// assume random is in [0,1] | |
int i = round(random() * 100) | |
if (i == 100) { | |
return UBELIEVABLE_JACKPOT // May never happen | |
} else if (i > 95) { | |
return BIGGEST_PRIZE // about once in 20 rolls | |
} else if (i > 75) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
senderThread = new Thread() { | |
run () { | |
while (!runSender) { | |
int id = nextIdFromQueue(); | |
if (id == null) { | |
Thread.currentThread().sleep(50) | |
continue; | |
} else { | |
byte[] data = RMS.read(id); | |
RMS.remove(id); // данные прочитали, убили из хранилища. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/wait.h> | |
int main(void) { | |
int status, w; | |
pid_t pid; |