Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View CremboC's full-sized avatar

Paulius Imbrasas CremboC

  • Permutive
  • United Kingdom
View GitHub Profile
package eu.crembo;
/**
* Bounded buffer problem.
* <p/>
* 2 Consumers and 2 Producers.
* Producers puts items into buffer - make sure it doesn't put into full buffer.
* Consumer uses items from buffer - make sure it doesn't take from empty buffer.
*/
public class Main {
package eu.crembo;
/**
* Created by Crembo on 2014-05-13.
*/
public class Task3 {
public static final int LIMIT = 50000;
public static final int CONSUMER_NUM = 2;
public static final int PRODUCER_NUM = 2;
package eu.crembo;
import java.util.ArrayList;
/**
* Bounded buffer problem.
* <p/>
* 2 Consumers and 2 Producers.
* Producers puts items into buffer - make sure it doesn't put into full buffer.
* Consumer uses items from buffer - make sure it doesn't take from empty buffer.
/**
* Put an item into the bounded buffer
*
* @param itm
* @throws InterruptedException
*/
public void put(int itm) throws InterruptedException {
enter();
boolean acquired = false;
package eu.crembo;
/**
* Created by Crembo on 2014-05-13.
*/
public class Task3 {
public static final int LIMIT = 100;
public static final int NUM = 3;
public static BoundedBuffer b;
package eu.crembo;
/**
* Bounded buffer problem.
* <p/>
* 2 Consumers and 2 Producers.
* Producers puts items into buffer - make sure it doesn't put into full buffer.
* Consumer uses items from buffer - make sure it doesn't take from empty buffer.
*/
public class Task2 {
require 'fileutils'
if ARGV[0].nil? || ARGV[1].nil?
puts 'Must define where to and from to copy',
'Usage: movejars <from> <to>',
'May use . to say "current folder"'
exit 0
end
$from = ARGV[0].dup
<?hh
ini_set('memory_limit','2048M');
$start = microtime(true);
/* The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
contributed by Peter Baltruschat
modified by Levi Cameron
modified by Craig Russell
*/
@CremboC
CremboC / after.java
Created April 16, 2015 11:03
StaleObjectException :D
final Collection<Sample> allByBarcode = sampleService.byBarcode(groupRequest.getSamples(), currentUser);
if (!allByBarcode.isEmpty()) {
Group group = new Group();
group.setName(groupRequest.getName());
group.setSamples(allByBarcode);
group.setType(groupRequest.getType());
group.setOwner(currentUser);
@Override
public Set<Sample> samplesFromGroups(Collection<Long> ids) {
return repository.findAllByIdIn(ids) // get all groups
.stream()
.map(Group::getSamples) // get samples of each group
.flatMap(Set::stream) // flatten into a single set of samples
.collect(toSet());
}
@Override