In this paper, we use three operators called K-, A-, and B-operators to define the equation of motion of an oscillator. In contrast to fractional integral and derivative operators which use fractional power kernels or their variations in their definitions, the K-, A-, and B-operators allow the kernel to be arbitrary. In the case, when the kernel is a power kernel, these operators reduce to fractional integral and derivative operators. Thus, they are more general than the fractional integral and derivative operators. Because of the general nature of the K-, A-, and B-operators, the harmonic oscillators are called the generalized harmonic oscillators. The equations of motion of a generalized harmonic oscillator are obtained using a generalized Euler–Lagrange equation presented recently. In general, the resulting equations cannot be solved in closed form. A finite difference scheme is presented to solve these equations. To verify the effectiveness of the numerical scheme, a problem is considered for which a closed form solution could be found. Numerical solution for the problem is compared with the analytical solution, which demonstrates that the numerical scheme is convergent.