public void beginThreadTransaction(int mode) {
		switch (mode) {
		case SERIALIZABLE_TRANSACTION:
			if (multiclientSupport) {
				throw new IllegalArgumentException("Illegal transaction mode");
			}

			useSerializableTransactions = true;
			getTransactionContext().nested += 1;
			;
			break;
		case EXCLUSIVE_TRANSACTION:
		case COOPERATIVE_TRANSACTION:
			if (multiclientSupport) {
				if (mode == EXCLUSIVE_TRANSACTION) {
					transactionLock.exclusiveLock();
				}
				else {
					transactionLock.sharedLock();
				}

				synchronized (transactionMonitor) {
					if (nNestedTransactions++ == 0) {
						file.lock(mode == READ_ONLY_TRANSACTION);
						byte[] buf = new byte[Header.sizeof];
						int rc = file.read(0, buf);

						if (rc > 0 && rc < Header.sizeof) {
							throw new StorageError(
									StorageError.DATABASE_CORRUPTED);
						}

						header.unpack(buf);
						int curr = header.curr;
						currIndex = curr;
						currIndexSize = header.root[1 - curr].indexUsed;
						committedIndexSize = currIndexSize;
						usedSize = header.root[curr].size;

						if (header.transactionId != transactionId) {
							if (bitmapPageAvailableSpace != null) {
								for (int i = 0; i < bitmapPageAvailableSpace.length; i++) {
									bitmapPageAvailableSpace[i] = Integer.MAX_VALUE;
								}
							}

							objectCache.clear();
							pool.clear();
							transactionId = header.transactionId;
						}
					}
				}
			}
			else {
				synchronized (transactionMonitor) {
					if (scheduledCommitTime != Long.MAX_VALUE) {
						nBlockedTransactions += 1;

						while (System.currentTimeMillis() >= scheduledCommitTime) {
							try {
								transactionMonitor.wait();
							}
							catch (InterruptedException x) {}
						}

						nBlockedTransactions -= 1;
					}

					nNestedTransactions += 1;
				}

				if (mode == EXCLUSIVE_TRANSACTION) {
					transactionLock.exclusiveLock();
				}
				else {
					transactionLock.sharedLock();
				}
			}
			break;
		default:
			throw new IllegalArgumentException("Illegal transaction mode");
		}
	}