Commit 32973123 authored by Roumen Petrov's avatar Roumen Petrov

initialize terminal emulator synchronously(II)

Restore previous code but now in synchronized statement.
Also let restore set of "is running" flag before to start threads.
parent fb6540c1
......@@ -126,7 +126,19 @@ protected void onProcessExit() {
* @param rows The number of rows in the terminal window.
*/
public void initializeEmulator(int columns, int rows) {
initializeEmulatorLocal(columns, rows);
synchronized (this) {
if (is_running) return;
mTranscriptScreen = new TranscriptScreen(columns, TRANSCRIPT_ROWS, rows, mColorScheme);
mEmulator = new TerminalEmulator(this, mTranscriptScreen, columns, rows, mColorScheme);
mEmulator.setKeyListener(mKeyListener);
is_running = true;
mReaderThread.start();
mWriterThread.start();
}
}
/**
......@@ -500,20 +512,6 @@ public void finish() {
finalizeEmulator();
}
private synchronized void initializeEmulatorLocal(int columns, int rows) {
if (is_running) return;
mTranscriptScreen = new TranscriptScreen(columns, TRANSCRIPT_ROWS, rows, mColorScheme);
mEmulator = new TerminalEmulator(this, mTranscriptScreen, columns, rows, mColorScheme);
mEmulator.setKeyListener(mKeyListener);
mReaderThread.start();
mWriterThread.start();
is_running = true;
}
private synchronized void finalizeEmulator() {
if (mFinishCallback != null) {
mFinishCallback.onSessionFinish(this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment