Skip to content

Instantly share code, notes, and snippets.

View mrWinston's full-sized avatar

Marius Schulz mrWinston

  • Red Hat
  • Rostock, Germany
View GitHub Profile
@mrWinston
mrWinston / FuturesConcurrency.java
Last active October 6, 2017 12:06
Java Futures usage #java #future #concurrency #multithreading #communication
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/
/**
* Executes Multiple futures
*
*/
@mrWinston
mrWinston / SingletonEnum.java
Last active July 13, 2016 13:47
Java Singleton by Enum #enum #singleton #pattern #design
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/
public enum EnumSingleton {
INSTANCE;
@mrWinston
mrWinston / MergeSort.java
Last active August 29, 2015 14:23 — forked from louisbros/MergeSort.java
Merge Sort Class #Sort #java #merge #comparable
package com.test;
import java.util.ArrayList;
import java.util.List;
public class MergeSort<T extends Comparable<T>> {
public void sort(List<T> values){
mergeSort(0, values.size() - 1, values, new ArrayList<T>(values));
}
@mrWinston
mrWinston / privMethInv.java
Last active October 21, 2015 15:10
Java Private Method Invokation #java #private #reflection
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/
try {
Method m = Object.class.getDeclaredMethod("myPrivateMethod", String.class, Serializable[].class, MyParameterObject.class)
m.setAccessible(true);
@mrWinston
mrWinston / Deserialize.java
Last active October 21, 2015 15:10
Java Deserializing from File #java #serialization #file #stream
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/
try{
FileInputStream fileIn = new FileInputStream("object.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
@mrWinston
mrWinston / serialize.java
Last active October 21, 2015 15:10
Java Serializing Object to File #java #serialization #file #stream #writing
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/
try{
Object o = new Object();