@Override
	public void synchronize(List jobIds, long timeout, boolean dispose)
			throws DrmaaException {
		Pointer<Pointer<Byte>> jobIdsPointer = pointerToCStrings((String[]) jobIds
				.toArray());
		Buffer eb = newErrorBuffer();
		int result = drmaa_synchronize(
				jobIdsPointer,
				timeout,
				dispose ? 1 : 0,
				eb.getPointer(),
				eb.getLength());
		if (result != DRMAA_ERRNO_SUCCESS) {
			String errorMessage = eb.toString();
			DrmaaException e;
			switch (result) {
			case DRMAA_ERRNO_NO_ACTIVE_SESSION:
				e = new NoActiveSessionException(errorMessage);
				break;
			case DRMAA_ERRNO_RESUME_INCONSISTENT_STATE:
				e = new ResumeInconsistentStateException(errorMessage);
				break;
			case DRMAA_ERRNO_SUSPEND_INCONSISTENT_STATE:
				e = new SuspendInconsistentStateException(errorMessage);
				break;
			case DRMAA_ERRNO_HOLD_INCONSISTENT_STATE:
				e = new HoldInconsistentStateException(errorMessage);
				break;
			case DRMAA_ERRNO_RELEASE_INCONSISTENT_STATE:
				e = new ReleaseInconsistentStateException(errorMessage);
				break;
			case DRMAA_ERRNO_INVALID_JOB:
				e = new InvalidJobException(errorMessage);
				break;
			default:
				e = new PlainDrmaaException(errorMessage);
				break;
			}
			throw e;
		}

	}