Is the tension in both ends the same (on a massed string)?

If two blocks lay on a table and I pull the second block, as shown in the picture below. Is the tension in both ends of the string the same? (The string has a mass)

Suppose the string has length $L$ and mass $m$, and both boxes have mass $M$, then, as the total external force is $F$, the acceleration of all objects is $a$

$$a = \frac{F}{2M+m}.$$

Assuming the the string is pulled completely and stays horizontal (this is not true if it has a mass, but it simplifies the problem). This reduces the problem to one dimension and makes all the object have zero acceleration relative to eachother.

Both large masses accelerate with acceleration $a$. This means a net force of

$$F_{net} = Ma = \frac{1}{2+\frac{m}{M}} F.$$

According to Newton's third law, the force on the left side of the string is $-F_{net}$ and on the right side $F-F_{net}$ (to the right).

$$F_{left} = -\frac{1}{2+\frac{m}{M}} F,$$ $$F_{right} = F-\frac{1}{2+\frac{m}{M}} F=\frac{1+\frac{m}{M}}{2+\frac{m}{M}}F.$$

These tensions are only the same (and opposite) for $\frac{m}{M}\to0$, thus, for a massless rope.

A string/spring with a mass can definitely have a tension that is variable over its length:

• in a horizontal spring, you can have longitude waves.
• if you hang a spring/string by one end, the tension at the top carries the whole weight, the tension at the bottom is zero.
• etc...

In this specific example, you can probably assume that dynamic friction has created a force equilibrium where everything moves at equal constant speed. In that case, the net force on the spring must be 0. So, tension is equal on both sides.