
:- ensure_loaded(lockrw).

go :-
	start_scheduled_goal_caller,
	thread_create(hold, _, [alias(bart)]),
	thread_get_message(main, start),
	\+ with_write_lock(x, write('** Failed!'), 0.1),
	thread_send_message(bart, stop),
	thread_join(bart, true).

hold :-
	with_write_lock(x, ( thread_send_message(main, start),
			     thread_get_message(bart, stop)
			   )).

