Skip to content

Instantly share code, notes, and snippets.

@claudemartin
claudemartin / .java
Last active February 8, 2018 22:49 — forked from kaecy/.java
public static void main(String args[]) {
String str = "abc";
byte[] cstr = str.getBytes();
cstr[0] = 'b';
System.out.println(new String(cstr));
System.out.println(str); // still "abc" -> it has not changed
}
@claudemartin
claudemartin / SomeClass.java
Last active August 29, 2015 14:25 — forked from anonymous/SomeClass.java
game loop that can bepaused / stopped, now using a Lock.
package com.example.foo;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class SomeClass {
public static void main(final String[] args) {
final Thread thread = new Thread(SomeClass::gameLoop);