package ss.week7;_x000D_
_x000D_
import java.util.concurrent.locks.Lock;_x000D_
import java.util.concurrent.locks.ReentrantLock;_x000D_
_x000D_
public class ConcatThread extends Thread {_x000D_
	private static String text = ""; // global variable_x000D_
	private String toe; // niet static dus deze word nooit overschreven_x000D_
	private static Lock l = new ReentrantLock();_x000D_
_x000D_
	public ConcatThread(String toeArg) {_x000D_
		this.toe = toeArg;_x000D_
	}_x000D_
_x000D_
	public void run() {_x000D_
		l.lock();_x000D_
		text = text.concat(toe);		_x000D_
		l.unlock();_x000D_
	}_x000D_
_x000D_
	public static void main(String[] args) {_x000D_
		(new ConcatThread("one;")).start();_x000D_
		(new ConcatThread("two;")).start();_x000D_
_x000D_
		try {_x000D_
			Thread.sleep(100);_x000D_
		} catch (InterruptedException e) {_x000D_
			e.getMessage();_x000D_
		}_x000D_
		System.out.println(text);_x000D_
_x000D_
	}_x000D_
}_x000D_

// niet static dus deze word nooit overschreven_x000D_
package ss.week7;_x000D_
_x000D_
import java.util.concurrent.locks.Lock;_x000D_
import java.util.concurrent.locks.ReentrantLock;_x000D_
_x000D_
public class ConcatThread extends Thread {_x000D_
	private static String text = ""; // global variable_x000D_
	private String toe; // niet static<SUF>
	private static Lock l = new ReentrantLock();_x000D_
_x000D_
	public ConcatThread(String toeArg) {_x000D_
		this.toe = toeArg;_x000D_
	}_x000D_
_x000D_
	public void run() {_x000D_
		l.lock();_x000D_
		text = text.concat(toe);		_x000D_
		l.unlock();_x000D_
	}_x000D_
_x000D_
	public static void main(String[] args) {_x000D_
		(new ConcatThread("one;")).start();_x000D_
		(new ConcatThread("two;")).start();_x000D_
_x000D_
		try {_x000D_
			Thread.sleep(100);_x000D_
		} catch (InterruptedException e) {_x000D_
			e.getMessage();_x000D_
		}_x000D_
		System.out.println(text);_x000D_
_x000D_
	}_x000D_
}_x000D_
