By throwing a test charged particle into a Reissner-Nordstrom (RN) black hole, we test the validity of the first and second laws of thermodynamics and weak cosmic censorship conjecture (WCCC) with two types of boundary conditions, i.e., the asymptotically anti-de Sitter (AdS) space and a Dirichlet cavity wall placed in the asymptotically at space. For the RN-AdS black hole, the second law of thermodynamics is satisfied, and the WCCC is violated for both extremal and nearextremal black holes. For the RN black hole in a cavity, the entropy can either increase or decrease depending on the change in the charge, and WCCC is satisfied/violated for the extremal/nearextremal black hole. Our results indicate that there may be a connection between the black hole thermodynamics and the boundary condition imposed on the black hole.