Modifying thread pool involves multiple steps. First you have to get the Server configuration ID and using which you have to get the webcontainer ID. Once you get that you can perform the modify and then save the configuration to the master repository. Below commands might help you to achieve the same:
serid = AdminConfig.getid('/Server:server1')
webid = AdminConfig.list('WebContainer',serid)
AdminConfig.modify(webid,[['tuningParams', [['invalidationTimeout', '1800'], ['maxInMemorySessionCount', '40']]]])
AdminConfig.modify(webid,[['threadPool', [['inactivityTimeout', '1800'], ['isGrowable', 'false'], ['maximumSize', '29'], ['minimumSize', '5']]]])