I have a script.sh which I start in Xvfb new session this way:
Xvfb :10 -screen 0 1000x200x24 & export DISPLAY=":10" && script.sh
In script.sh I run one c++ program and one java program. However, I sometimes got errors in one or two of them: in c++ program I got Segmentation fault and java program I got exception something like awt can't get display:10. The errors disappeared when I added in the beginning of script.sh the line
sleep 2;
After that I didn't get any errors. How to explain it?