Lock the mex file to avoid Matlab crashes.

Commands like "clear all" and "clear function" causes segmentation faults or errors like these (especially after an 'init'):
 libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: caffe/proto/caffe.proto
 libprotobuf FATAL google/protobuf/descriptor.cc:862] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
 [libprotobuf ERROR google/protobuf/message.cc:333] Type appears to be in generated pool but wasn't registered: caffe.LayerParameter
 Attempt to restart MATLAB?
To avoid these, lock the the mex file.
Changed linking order: -pthread -> back.
Otherwise error:
/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): undefined reference to symbol 'pthread_rwlock_wrlock@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[pycaffe] add converter for vectors of Nets
[pycaffe] expose SGDSolver.test_nets
add accessor for Solver::iter_

This will be useful in code controlling the solver (from pycaffe, for
example).
[pycaffe] expose SGDSolver.iter
Back-merge branch 'master' into dev (for fix in PR #1203)
caffe.proto: do some minor cleanup (fix comments, alphabetization)
Merge pull request #951 from gcinbis/patch-1

Lock the mex file to avoid MATLAB crashes
[fix] lint causing travis failures
Back-merge to include #1198
add factory header to caffe hpp
Merge pull request #1196 from longjon/python-solver-improvements

Python solver improvements
Merge pull request #1208 from Yangqing/dev

add factory header to caffe hpp
Add caffe_gpu_exp math function
Add ExpLayer to calculate y = base ^ (scale * x + shift)
[fix] comment typo
save/restore shared weights unit test
Merge pull request #1204 from jeffdonahue/exp-layer

EXP neuron layer
Move data_mean into data_transformer remove datum_* from BaseData

Conflicts:

	src/caffe/layers/memory_data_layer.cpp