This invention provides thienopyrimidine derivatives of the formula,wherein R1 stands for hydrogen atom, an alkyl group or the like; R2 stands for a hydrogen atom, an alkyl or amino group or the like, R3 stands for an alkyl, alkenyl or alkylthio group or the like or a group Y—X—; or R2 and R3 may together form tetramethylene group; X standing for a direct bond or linking group such as CH2, CH(OH), S, O, NH; Y standing for a substituted or unsubstituted aromatic carbocycylic, aromatic heterocylic, cycloalkyl or saturated heterocyclic group or the like; Z stands for S or O, and n is 0 or an integer of 1 to 4,or salts thereof, which exhibit an inhibitory effect on PDE9, and are therefore useful for prevention or treatment of overactive bladder syndrome, pollakiuria, urinary incontinence, dysuria associated with prostatic hyperplasia, urolithiasis, Alzheimer's disease, chronic obstructive pulmonary disease, myocardial infarction, thrombosis, diabetes and the like.